PostgreSQL supports sending query results in text or binary format:
Currently, the QSQL plugin uses a text format that is less efficient than the binary format. Other libraries like Npgsql for C# use binary format and run much faster than QPSQL.
For example, getting the SQL query result:
for MSVC2015 + Qt 5.12.6 it takes:
and for .NET Framework 4.7.2 + Npgsql 4.1.2:
The tests I did show that changing the implementation from a text to binary format would give similar results as C #:
I think it would be worth considering the binary format for QPSQL in Qt6.
Below I describe what should be done to support the binary format:
- parse binary formats for different data types (see *send i *recv functions in PostgreSQL src\backend\utils\adt directory and https://www.npgsql.org/doc/dev/type-representations.html)
- split SQL queries into individual SQL commands and use the PQsendQueryParams () function with the resultFormat = 1 parameter instead of PQsendQuery ()
- drop support for PostgreSQL 7.3, because it does not support binary format