Opened 18 years ago

Closed 18 years ago

Last modified 15 years ago

#364 closed enhancement (fixed)

'better' SQL to return results faster from the sample button in the query builder

Reported by: rhys.stewart@… Owned by: gsherman
Priority: minor: annoyance Milestone:
Component: Data Provider Version: 0.8
Keywords: querybuilder, qgspgquerybuilder.cpp Cc:
Must Fix for Release: No Platform: All
Platform Version: Awaiting user input: no

Description

Currently the sql that is used to return a subset of the values of a given column is:

SELECT DISTINCT mycolumn FROM mytable ORDER BY mycolumn LIMIT 25

this will be very slow on very large tables. On a table with ~670000 records this took about 15 seconds execute. A faster method would be a subselect as follows:

SELECT DISTINCT mycol from (SELECT mycol FROM mytable LIMIT 5000) as myfoo

This query took much less than a second to execute on the same table.

QgsPgQueryBuilder::on_btnSampleValues_clicked()

Attachments (1)

qgspgquerybuilder.cpp.diff (368 bytes ) - added by rhys.stewart@… 18 years ago.

Download all attachments as: .zip

Change History (3)

by rhys.stewart@…, 18 years ago

Attachment: qgspgquerybuilder.cpp.diff added

comment:1 by g_j_m, 18 years ago

Resolution: fixed
Status: newclosed

Applied in svn r6032

Thanks for the improvement.

comment:2 by (none), 15 years ago

Milestone: Version 0.8

Milestone Version 0.8 deleted

Note: See TracTickets for help on using tickets.