Re: Terribly slow query with very good plan?

From: Les <nagylzs(at)gmail(dot)com>
To: Nick Cleaton <nick(at)cleaton(dot)net>
Cc: pgsql-performance(at)lists(dot)postgresql(dot)org
Subject: Re: Terribly slow query with very good plan?
Date: 2022-02-04 10:09:52
Message-ID: CAKXe9UA_E99+E3rL45PtXR5fCkZA+ttj8o5oKAQMqmrn5c4=PA@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-performance

> In the fast case the 'Felhasználók%' part is known at query planning
>> time, so it can be a prefix search.
>>
>> In the slow case, the planner doesn't know what that value will be, it
>> could be something that starts with '%' for example.
>>
>>
> First of all, it CANNOT start with '%'. This is a fact and this fact can
> be determined by analyzing the query. Something that the query planner
> should do, right?
>
> Second argument: the same query is also slow with the ^@ operator...
>

Oh I see, the query planner does not know that there will be no %
characters in file and folder names.

But what is the solution then? It just seems wrong that I can speed up a
query 1000 times by replacing it with a nested loop in a pl/sql function :(

In response to

Responses

Browse pgsql-performance by date

  From Date Subject
Next Message Les 2022-02-04 10:38:53 Re: Terribly slow query with very good plan?
Previous Message Les 2022-02-04 10:05:13 Re: Terribly slow query with very good plan?