Re: Postgres chooses slow query plan from time to time - Mailing list pgsql-performance

From Tom Lane
Subject Re: Postgres chooses slow query plan from time to time
Date
Msg-id 632224.1631634441@sss.pgh.pa.us
Whole thread Raw
In response to Re: Postgres chooses slow query plan from time to time  (Kristjan Mustkivi <sonicmonkey@gmail.com>)
Responses Re: Postgres chooses slow query plan from time to time  (Kristjan Mustkivi <sonicmonkey@gmail.com>)
List pgsql-performance
Kristjan Mustkivi <sonicmonkey@gmail.com> writes:
>>> Filter: (((product_code)::text = ($1)::text) AND
>>> ((balance_type)::text = ($4)::text))

> But the Primary Key is defined as btree (cage_code, cage_player_id,
> product_code, balance_type, version) so this should be exactly that
> (apart from the extra "version" column).

Oh, interesting.  So this is really a datatype mismatch problem.
I'd wondered idly why you were getting the explicit casts to text
in these conditions, but now it seems that that's key to the
problem: the casts prevent these clauses from being matched to
the index.  What are the declared data types of product_code
and balance_type?  And of the parameters they're compared to?

            regards, tom lane



pgsql-performance by date:

Previous
From: Kristjan Mustkivi
Date:
Subject: Re: Postgres chooses slow query plan from time to time
Next
From: manish yadav
Date:
Subject: Re: EnterpriseDB