pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Need help on a troublesome query plan
4+ messages / 2 participants
[nested] [flat]

* Need help on a troublesome query plan
@ 2002-07-16 17:24  Alain Lavigne <alavigne@zaq.com>
  0 siblings, 1 reply; 4+ messages in thread

From: Alain Lavigne @ 2002-07-16 17:24 UTC (permalink / raw)
  To: pgsql-sql

On PostgreSQL Version 7.2.1 on Redhat Linux 7.1

Table bld_tb_bus_fact definition
================================

     Column         |           Type           | Modifiers 
-----------------+--------------------------         +-----------
 bus_fact_id        | bigint                    | not null
 bus_fact_ts        | timestamp with time zone | not null
 party_id             | bigint                    | 
 svc_id                | bigint                    | not null
 bus_fact_data     | text                      | not null
 bus_fact_typ_cd | character(10)            | not null
 bus_fact_kywrd   | character varying(300)   | 
 cont_id                | bigint                   | 
 perfby_id             | bigint                   | 
 
    Index "bld_x1_tb_bus_fact"
     Column      |     Type      
-----------------+---------------
 party_id        | bigint
 bus_fact_typ_cd | character(10)
 cont_id         | bigint
btree

With the following query on 50000 records:

explain
SELECT  bld_TB_BUS_FACT.BUS_FACT_ID AS id
FROM    bld_TB_BUS_FACT
WHERE   bld_TB_BUS_FACT.PARTY_ID=1320677
AND     bld_TB_BUS_FACT.BUS_FACT_TYP_CD='MSG_SENT'
AND     bld_TB_BUS_FACT.CONT_ID=786448
AND     bld_TB_BUS_FACT.BUS_FACT_KYWRD ILIKE '%MT-ID=3407979%'
AND     bld_TB_BUS_FACT.BUS_FACT_KYWRD ILIKE '%S-ID=1310723%'
limit 1;

psql:test.sql:9: NOTICE:  QUERY PLAN:

Limit  (cost=0.00..2264.16 rows=1 width=8)
  ->  Seq Scan on bld_tb_bus_fact  (cost=0.00..2264.16 rows=1 width=8)

EXPLAIN

I don't understand why it's not using the defined index, even after performing VACUUM FULL ANALYZE on the table.
I tried disabling seqscan but that didn't change anything.

I'm open to suggestions anyone

Thanks!

----------------------------------------------------------------------------------------
Alain Lavigne - Data Administrator - ZAQ Interactive Solutions  E-Mail: alavigne@zaq.com
297 St-Paul, West - Montreal, Quebec, Canada  - H2Y 2A5
Phone: 514-282-7073 ext: 371 - Fax: 514-282-8011




^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: Need help on a troublesome query plan
@ 2002-07-16 18:52  Stephan Szabo <sszabo@megazone23.bigpanda.com>
  parent: Alain Lavigne <alavigne@zaq.com>
  0 siblings, 0 replies; 4+ messages in thread

From: Stephan Szabo @ 2002-07-16 18:52 UTC (permalink / raw)
  To: Alain Lavigne <alavigne@zaq.com>; +Cc: pgsql-sql


On Tue, 16 Jul 2002, Alain Lavigne wrote:

>     Index "bld_x1_tb_bus_fact"
>      Column      |     Type
> -----------------+---------------
>  party_id        | bigint
>  bus_fact_typ_cd | character(10)
>  cont_id         | bigint
> btree
>
> With the following query on 50000 records:
>
> explain
> SELECT  bld_TB_BUS_FACT.BUS_FACT_ID AS id
> FROM    bld_TB_BUS_FACT
> WHERE   bld_TB_BUS_FACT.PARTY_ID=1320677
> AND     bld_TB_BUS_FACT.BUS_FACT_TYP_CD='MSG_SENT'
> AND     bld_TB_BUS_FACT.CONT_ID=786448
> AND     bld_TB_BUS_FACT.BUS_FACT_KYWRD ILIKE '%MT-ID=3407979%'
> AND     bld_TB_BUS_FACT.BUS_FACT_KYWRD ILIKE '%S-ID=1310723%'
> limit 1;

You'll need to either single quote or explicitly cast the
constants you're comparing to the bigint columns.




^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: Need help on a troublesome query plan
@ 2002-07-16 19:02  Alain Lavigne <alavigne@zaq.com>
  0 siblings, 1 reply; 4+ messages in thread

From: Alain Lavigne @ 2002-07-16 19:02 UTC (permalink / raw)
  To: Stephan Szabo <sszabo@megazone23.bigpanda.com>; +Cc: pgsql-sql

Thanks that worked, but why does that happen or maybe you could point to the proper thread so I read up on it.



----------------------------------------------------------------------------------------
Alain Lavigne - Data Administrator - ZAQ Interactive Solutions  E-Mail: alavigne@zaq.com
297 St-Paul, West - Montreal, Quebec, Canada  - H2Y 2A5
Phone: 514-282-7073 ext: 371 - Fax: 514-282-8011


-----Original Message-----
From: Stephan Szabo [mailto:sszabo@megazone23.bigpanda.com]
Sent: July 16, 2002 14:52
To: Alain Lavigne
Cc: pgsql-sql@postgresql.org
Subject: Re: [SQL] Need help on a troublesome query plan



On Tue, 16 Jul 2002, Alain Lavigne wrote:

>     Index "bld_x1_tb_bus_fact"
>      Column      |     Type
> -----------------+---------------
>  party_id        | bigint
>  bus_fact_typ_cd | character(10)
>  cont_id         | bigint
> btree
>
> With the following query on 50000 records:
>
> explain
> SELECT  bld_TB_BUS_FACT.BUS_FACT_ID AS id
> FROM    bld_TB_BUS_FACT
> WHERE   bld_TB_BUS_FACT.PARTY_ID=1320677
> AND     bld_TB_BUS_FACT.BUS_FACT_TYP_CD='MSG_SENT'
> AND     bld_TB_BUS_FACT.CONT_ID=786448
> AND     bld_TB_BUS_FACT.BUS_FACT_KYWRD ILIKE '%MT-ID=3407979%'
> AND     bld_TB_BUS_FACT.BUS_FACT_KYWRD ILIKE '%S-ID=1310723%'
> limit 1;

You'll need to either single quote or explicitly cast the
constants you're comparing to the bigint columns.




^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: Need help on a troublesome query plan
@ 2002-07-16 20:31  Stephan Szabo <sszabo@megazone23.bigpanda.com>
  parent: Alain Lavigne <alavigne@zaq.com>
  0 siblings, 0 replies; 4+ messages in thread

From: Stephan Szabo @ 2002-07-16 20:31 UTC (permalink / raw)
  To: Alain Lavigne <alavigne@zaq.com>; +Cc: pgsql-sql

On Tue, 16 Jul 2002, Alain Lavigne wrote:

> Thanks that worked, but why does that happen or maybe you could point
> to the proper thread so I read up on it.

It's an issue that the numeric constant gets cast to int4 somewhat
prematurely.  I don't have a pointer to a thread off hand, but if you
search the archives you should find a couple.





^ permalink  raw  reply  [nested|flat] 4+ messages in thread


end of thread, other threads:[~2002-07-16 20:31 UTC | newest]

Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2002-07-16 17:24 Need help on a troublesome query plan Alain Lavigne <alavigne@zaq.com>
2002-07-16 18:52 ` Stephan Szabo <sszabo@megazone23.bigpanda.com>
2002-07-16 19:02 Re: Need help on a troublesome query plan Alain Lavigne <alavigne@zaq.com>
2002-07-16 20:31 ` Stephan Szabo <sszabo@megazone23.bigpanda.com>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox