In my PostgreSQL database, I have this table:
Table "public.data"
Column | Type | Modifiers
-----------+--------+-----------
group_id | bigint |
item | text |
price | real |
Indexes:
"group_id_index" btree (group_id)
item
's are organized into groups, and the group_id
column will have individual values appearing many times in the table. Queries to this table have the form:
SELECT item, price FROM data WHERE group_id = 1234;
group_id_index
speeds up these queries (as is its purpose).
My question is, does the presence of the index make Postgres realize it does not have to store the group_id
column behind-the-scenes? If only one copy (for the index) of each value of group_id
is stored, that would save a lot of space.
This is, if it matters, PostgreSQL version 9.4.1
-
29.4.1? Upgrade NOW. Why on earth would you keep running an old point release like that? In this case there are known serious bugs in 9.4.1. Upgrade urgently to the latest in the 9.4.x series. You do not need to dump and reload, just install the new binaries.Craig Ringer– Craig Ringer2017年11月14日 02:35:53 +00:00Commented Nov 14, 2017 at 2:35
-
I appreciate the suggestion, but unfortunately it's not in my control. This database lives on a shared virtual cluster that is updated pretty infrequentlyAntsySysHack– AntsySysHack2017年11月14日 19:10:58 +00:00Commented Nov 14, 2017 at 19:10
-
then migrate somewhere else, because that one's going to destroy your data.There are severe bugs in 9.4.1. Read the release notes. Get regular dumps going. And plan your migration.Craig Ringer– Craig Ringer2017年11月15日 00:52:47 +00:00Commented Nov 15, 2017 at 0:52
1 Answer 1
My question is, does the presence of the index make Postgres realize it does not have to store the group_id column behind-the-scenes?
No. PostgreSQL uses heaps, not index-organised tables.
-
Hi Craig, thanks for your answer, but can you expand on it or provide any references?AntsySysHack– AntsySysHack2017年11月14日 19:08:53 +00:00Commented Nov 14, 2017 at 19:08
-
@AntsySysHack The source code is the primary reference here. But it's the absence of references - there's nothing that says it does do what you want.Craig Ringer– Craig Ringer2017年11月15日 00:53:35 +00:00Commented Nov 15, 2017 at 0:53
Explore related questions
See similar questions with these tags.