<resend to mailing list> On Thu, Jun 24, 2010 at 16:57, Thom Brown <thombrown@xxxxxxxxx> wrote: > Sounds like the planner took a wrong turn in the 2nd case. Which > version of PostgreSQL are you running? PostgreSQL version 8.1.21 (With schemas) The explain commands show that: db1=> explain select * from emails where email_msg_id = '4dba381b-f55e-02d3-4b4a-95e2e98178e2' limit 1; QUERY PLAN ------------------------------------------------------------------------------------------------------------------- Limit (cost=0.00..4.00 rows=1 width=184) -> Index Scan using idx_emails_email_msg_id on emails (cost=0.00..370016.42 rows=92413 width=184) Index Cond: (email_msg_id = '4dba381b-f55e-02d3-4b4a-95e2e98178e2'::bpchar) (3 rows) db1=> explain select * from emails where email_msg_id = '4dba381b-f55e-02d3-4b4a-95e2e98178e2' and email_sender = 'sender@xxxxxxxxxx' limit 1; QUERY PLAN --------------------------------------------------------------------------------------------------------------------------------------------------------- Limit (cost=0.00..801.06 rows=1 width=184) -> Index Scan using idx_emails_email_sender on emails (cost=0.00..370089.46 rows=462 width=184) Index Cond: (email_sender = 'sender@xxxxxxxxxx'::text) Filter: (email_msg_id = '4dba381b-f55e-02d3-4b4a-95e2e98178e2'::bpchar) (4 rows) -- Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-general