Re: Forcing Index usage

2025-11-13 Thread pg254kl
Divide and conquer.  Get rid of the CTE temporarily. create temp table temp_search as ; -- index temp_search *appropriately* analyze temp_search; Use it instead of the CTE. Remove the ORDER BY temporarily. Work on putting the right indices in place to make the above run fast. I assume you h

Re: Forcing Index usage

2025-11-13 Thread Tom Lane
Greg Sabino Mullane writes: > Please provide a self-contained use case, or (at the bare minimum) trim out > the irrelevant parts of your query and show us the schema for the tables in > question. Finally, please show the explain plans for the "good" and "bad" > runs you are experiencing. Thanks.

Re: Forcing Index usage

2025-11-13 Thread Greg Sabino Mullane
Please provide a self-contained use case, or (at the bare minimum) trim out the irrelevant parts of your query and show us the schema for the tables in question. Finally, please show the explain plans for the "good" and "bad" runs you are experiencing. Thanks. Cheers, Greg -- Crunchy Data - http

Re: Forcing index usage

2019-04-24 Thread Jeff Janes
On Wed, Apr 3, 2019 at 12:13 PM Jonathan Marks wrote: Is there a way to tell Postgres “please don’t use index X when queries that > could use index Y instead occur?” > Late to the party here, but... Not directly. I've had luck in changing the procost of functions (or the functions which back t

Re: Forcing index usage

2019-04-17 Thread Bruce Momjian
On Wed, Apr 17, 2019 at 11:16:28AM -0600, Michael Lewis wrote: > > * Michael Lewis ([email protected]) wrote: > > > Thanks for that advance warning since it is a handy option to force > the > > > planning barrier in my experience. What's a resource to see other > coming > > >

Re: Forcing index usage

2019-04-17 Thread Michael Lewis
> > > * Michael Lewis ([email protected]) wrote: > > > Thanks for that advance warning since it is a handy option to force the > > > planning barrier in my experience. What's a resource to see other > coming > > > changes in v12 especially changes to default behavior like this? Will > there > > >

Re: Forcing index usage

2019-04-17 Thread Bruce Momjian
On Wed, Apr 3, 2019 at 03:28:48PM -0400, Stephen Frost wrote: > Greetings, > > * Michael Lewis ([email protected]) wrote: > > Thanks for that advance warning since it is a handy option to force the > > planning barrier in my experience. What's a resource to see other coming > > changes in v12 es

Re: Forcing index usage

2019-04-03 Thread Stephen Frost
Greetings, * Michael Lewis ([email protected]) wrote: > Thanks for that advance warning since it is a handy option to force the > planning barrier in my experience. What's a resource to see other coming > changes in v12 especially changes to default behavior like this? Will there > be a new cte_c

Re: Forcing index usage

2019-04-03 Thread Michael Lewis
Thanks for that advance warning since it is a handy option to force the planning barrier in my experience. What's a resource to see other coming changes in v12 especially changes to default behavior like this? Will there be a new cte_collapse_limit setting or similar?

Re: Forcing index usage

2019-04-03 Thread Stephen Frost
Greetings, * Michael Lewis ([email protected]) wrote: > > Is there a way to tell Postgres “please don’t use index X when queries > > that could use index Y instead occur?” > > No. But you could re-write the query to make the date index useless. The > simplest way that comes to mind is putting th

Re: Forcing index usage

2019-04-03 Thread Michael Lewis
> > Is there a way to tell Postgres “please don’t use index X when queries > that could use index Y instead occur?” > No. But you could re-write the query to make the date index useless. The simplest way that comes to mind is putting the query that does your full-text search in a CTE (WITH keyword