postgres_scanner icon indicating copy to clipboard operation
postgres_scanner copied to clipboard

LIMIT is not pushed down

Open adriangb opened this issue 1 year ago • 4 comments

What happens?

If I do SELECT * FROM pg.very_large_table LIMIT 1; the query issued does not include a limit and thus the entire table is copied.

To Reproduce

D ATTACH '' AS pg (TYPE POSTGRES);
D SELECT * FROM pg.some_table; -- warm up schema cache
D SET pg_debug_show_queries = true;
D SELECT * FROM pg.schema_name.very_large_table LIMIT 1;
BEGIN TRANSACTION ISOLATION LEVEL REPEATABLE READ

        COPY (SELECT <lots of columns> FROM "schema_name"."very_large_table" ) TO STDOUT (FORMAT binary);

I don't see any pagination happening either.

My network usage goes through the roof as well (indicating lots of data is being copied).

OS:

MacOS

PostgreSQL Version:

15 (timescale)

DuckDB Version:

v0.10.4-dev124 cf5b770ccb

DuckDB Client:

CLI

Full Name:

Adrian Garcia Badaracco

Affiliation:

Pydantic

Have you tried this on the latest main branch?

  • [X] I agree

Have you tried the steps to reproduce? Do they include all relevant data and configuration? Does the issue you report still appear there?

  • [X] I agree

adriangb avatar May 31 '24 07:05 adriangb