From: | "Christopher Kings-Lynne" <chriskl(at)familyhealth(dot)com(dot)au> |
---|---|
To: | <denis(at)next2me(dot)com>, <josh(at)agliodbs(dot)com>, <pgsql-performance(at)postgresql(dot)org> |
Subject: | Re: [SQL] Yet Another (Simple) Case of Index not used |
Date: | 2003-04-09 02:35:22 |
Message-ID: | 077201c2fe40$ab420d70$6500a8c0@fhp.internal |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general pgsql-performance pgsql-sql |
Hi Denis,
> The kind of requests that I am really interested in are:
> select count(*) from table where table.column like 'pattern%'
> These seems to go much master on mysql (which I guess it not a MVCC database? or wasn't
> the Innobase supposed to make it so?), than on postgresql.
A few things.
* MVCC in PostgreSQL allows us to be way faster than MySQL when you have heaps of concurrent readers and writers. The tradeoff is that count(*) is slow since PostgreSQL needs to check that each tuple is actually visible to your query (eg. you start a transaction, somone else inserts a row, you do a count(*) - should the result include that new row or not? Answer: no.)
* Just avoid doing count(*) over the entire table with no where clause!!! It's as easy as that
* The LIKE 'pattern%' is indexable in Postgresql. You will need to create a normal btree index over table.column. So long as the index is returning a small portion of the table (eg. say only 5-10% of the fields begin with pattern), then the index will be used and it will be fast.
* If you want really fast full text indexing, check out contrib/tsearch - it's really, really, really fast.
Chris
From | Date | Subject | |
---|---|---|---|
Next Message | Martijn van Oosterhout | 2003-04-09 03:18:39 | Re: [GENERAL] Yet Another (Simple) Case of Index not used |
Previous Message | Stephan Szabo | 2003-04-09 01:59:37 | Re: [SQL] Yet Another (Simple) Case of Index not used |
From | Date | Subject | |
---|---|---|---|
Next Message | Martijn van Oosterhout | 2003-04-09 03:18:39 | Re: [GENERAL] Yet Another (Simple) Case of Index not used |
Previous Message | Stephan Szabo | 2003-04-09 01:59:37 | Re: [SQL] Yet Another (Simple) Case of Index not used |
From | Date | Subject | |
---|---|---|---|
Next Message | Martijn van Oosterhout | 2003-04-09 03:18:39 | Re: [GENERAL] Yet Another (Simple) Case of Index not used |
Previous Message | Stephan Szabo | 2003-04-09 01:59:37 | Re: [SQL] Yet Another (Simple) Case of Index not used |