Search Postgresql Archives

LIKE conditions in PGSQL very, very slow!

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

I'm moving from the mysql camp and quite liking things like functions
and such, but a lot of my functionality depends on queries such as

   SELECT id, name, start_date
   FROM customer
   WHERE name LIKE 'eri%';

These kinds of queries are super fast in MySQL because "eri%" type
conditions also use the index. Is this not the case with PG?

Here's the EXPLAIN output:


CUSTDB=# explain select id,name,start_date from customer where name
like 'eri%';
                           QUERY PLAN
----------------------------------------------------------------
 Seq Scan on customer  (cost=0.00..86032.18 rows=1 width=111)
   Filter: ((name)::text ~~ 'eri%'::text)
(2 rows)


Would appreciate any thoughts on how to make these kinds of queries
faster. I found a message (http://archives.postgresql.org/pgsql-sql/
1999-12/msg00218.php) but that's from 1999.

While we're at it, are compound indexes ok in PGSQL as well? In MySQL,
the order of columns is important if it reflects my WHERE conditions
in SQL. Should I follow the same structure in PGSQL? I tried looking
at the manual but did not find a section that talks about indexing in
detail. Would appreciate pointers.

Thanks!


---------------------------(end of broadcast)---------------------------
TIP 5: don't forget to increase your free space map settings

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux