Re: planner/optimizer question

From: "Atesz" <atesz(at)ritek(dot)hu>
To: <pgsql-performance(at)postgresql(dot)org>
Subject: Re: planner/optimizer question
Date: 2004-04-27 12:54:27
Message-ID: 002901c42c56$c8e077a0$0b02010a@atesz
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

Hi,

You should try the next queries:

select support_person_id from ticket_crm_map where crm_id = 7 GROUP BY
support_person_id;
select support_person_id from ticket_crm_map where crm_id = 1 GROUP BY
support_person_id;

It can use the 'ticket_crm_map_crm_id_suppid' index.

Generally the Postgres use an k-column index if columns of your
conditions are prefix of the index column.
For example:
CREATE INDEX test_idx on test(col1,col2,col3,col4);
SELECT * FROM test WHERE col1=3 AND col2=13; -- This can use the index.

But the next queries cannot use the index:
SELECT * FROM test WHERE col1=3 AND col3=13;.
SELECT * FROM test WHERE col2=3;

If you have problem with seq_scan or sort, you can disable globally and
locally:
SET enable_seqscan=0;
SET enable_sort = 0;

Regards, Antal Attila

In response to

Browse pgsql-performance by date

  From Date Subject
Next Message Christopher Kings-Lynne 2004-04-27 15:01:22 Re: [JDBC] [PERFORM] is a good practice to create an index on the
Previous Message Manfred Koizar 2004-04-27 12:12:20 Re: Shared buffers, Sort memory, Effective Cache Size