From: | "David Rowley" <dgrowley(at)gmail(dot)com> |
---|---|
To: | dmitry(at)koterov(dot)ru |
Cc: | "Postgres General" <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: Is index enough to do simple fetch, or table is always used too? |
Date: | 2008-12-14 12:36:05 |
Message-ID: | 663166fa0812140436x27856577m4dc3866300deccfd@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
2008/12/14 Dmitry Koterov <dmitry(at)koterov(dot)ru>:
> Hello.
>
> Suppose I have the following index:
>
> CREATE INDEX idx ON tbl USING btree (abc, def, id)
>
> and perform the query with index scan:
>
> SELECT md5(id)
> FROM tbl
> WHERE abc=1 AND def=2
> LIMIT 200
>
> The question: if the table "tbl" scanned to fetch "id" and calculate
> md5(id), or the value of "id" is brought directly from "idx" index with no
> table data access at all? The second behaviour is logical: why should we
> access the table if all the needed data is already in the index entry...
In fact not all the required information is in the index. Postgresql
uses Multi-version-concurrency-control, which means there may be multi
versions of the same row. Postgresql must hit the heap (table) no get
the visibility information.
>
> (Some time ago I have read something about this behaviour somewhere, but now
> cannot find it in the PostgreSQL documentation. Possibly it were words about
> another database, not Postges?)
>
>
Maybe here? http://www.postgresql.org/docs/8.3/static/mvcc.html
David
From | Date | Subject | |
---|---|---|---|
Next Message | paulo matadr | 2008-12-14 15:39:21 | Urgente error in restore prod |
Previous Message | Dmitry Koterov | 2008-12-14 12:21:54 | Is index enough to do simple fetch, or table is always used too? |