Limit Heap Fetches / Rows Removed by Filter in Index Scans

Поиск
Список
Период
Сортировка
От Victor Blomqvist
Тема Limit Heap Fetches / Rows Removed by Filter in Index Scans
Дата
Msg-id CAL870DXiKS7Dyj752yK6dG7qwBQaBqqifDzwgiJH5C=mdJCm=A@mail.gmail.com
обсуждение исходный текст
Ответы Re: Limit Heap Fetches / Rows Removed by Filter in Index Scans  (Sameer Kumar <sameer.kumar@ashnik.com>)
Re: Limit Heap Fetches / Rows Removed by Filter in Index Scans  (Francisco Olarte <folarte@peoplecall.com>)
Список pgsql-general
Hi,

Is it possible to break/limit a query so that it returns whatever results found after having checked X amount of rows in a index scan?

For example:
create table a(id int primary key);
insert into a select * from generate_series(1,100000);

select * from a
where id%2 = 0
order by id limit 10

In this case the query will "visit" 20 rows and filter out 10 of them. We can see that in the query plan:
"Rows Removed by Filter: 10"
"Heap Fetches: 20"

Is it somehow possible to limit this query so that it only fetches X amount, in my example if we limited it to 10 Heap Fetches the query could return the first 5 rows?


My use case is I have a table with 35 million rows with a geo index, and I want to do a KNN search but also limit the query on some other parameters. In some cases the other parameters restrict the query so much that Heap Fetches becomes several 100k or more, and in those cases I would like to have a limit to my query.

Thanks!
/Victor

В списке pgsql-general по дате отправления:

Предыдущее
От: "Alexander M. Sauer-Budge"
Дата:
Сообщение: Restrict CREATEROLE privilege grant to NOLOGIN only?
Следующее
От: Sameer Kumar
Дата:
Сообщение: Re: Limit Heap Fetches / Rows Removed by Filter in Index Scans