I realized only after writing this that it's about what you've already mentioned in trac#16.
Postgres PQexecParams (but not PQexec) has resultFormat which allows the data to be transmitted in binary format: https://www.postgresql.org/docs/current/libpq-exec.html |resultFormat |Specify zero to obtain results in text format, or one to obtain results in binary format. (There is not currently a provision to obtain different result columns in different formats, although that is possible in the underlying protocol.) Pygres query_formatted does: | result = PQexecParams(self->cnx, query, nparms, | NULL, parms, NULL, NULL, 0); Setting format=1 breaks pygres getresult(): getresult: | /* get the string representation of the value */ | /* note: this is always null-terminated text format */ | char *s = PQgetvalue(self->result, i, j); |.........EEEEEEE..EE..EEEE.EEEEEE......EEEEEEEEEE.EE....E...EEEFEEEEEEEEEE...E..EF.EEEE.......EEEEE........EEEEEEEEEEE................F...................EEEEEEE..EE..EEEE.EEEEEE......EEEEEEEEEE.EE....E...EEEFEEEEEEEEEE...E..EF.EEEE.......EEEEE........EEEEEEEEEEE.......EEEE.E postgres: |PQgetvalue |For data in text format, the value returned by PQgetvalue is a null-terminated character string representation of the field value. For data in binary format, the value is in the binary representation determined by the data type's typsend and typreceive functions. (The value is actually followed by a zero byte in this case too, but that is not ordinarily useful, since the value is likely to contain embedded nulls.) I doubt it's easily possible, but what would it take to receive data in binary format ? It occurs to me that not only is it possible, and desirable, to change query to use PQexecParams, in addition to query_formatted, it's maybe necessary and/or easier, since getresult() would otherwise the query object would maybe need to store the format option, and getresult would have to branch to interpret the results. Note that libpq doesn't allow the possibility to handling binary only for "easy" columns types like ints, it's all or nothing. My interest is in saving RAM (same as cursor project): |[pryzbyj@telsasoft PyGreSQL]$ PYTHONPATH=build/lib.linux-x86_64-2.7/ command time -v strace -fe recvfrom python2.7 -c "import pg; pg.DB('ts').query_formatted('SELECT * FROM generate_series(1,%s)', [999999]).getresult()" 2>&1 |less Maximum resident set size (kbytes): 50220 vs. |[pryzbyj@telsasoft PyGreSQL]$ xPYTHONPATH=build/lib.linux-x86_64-2.7/ command time -v strace -fe recvfrom python2.7 -c "import pg; pg.DB('ts').query_formatted('SELECT * FROM generate_series(1,%s)', [999999]).getresult()" 2>&1 |less Maximum resident set size (kbytes): 137656 Justin _______________________________________________ PyGreSQL mailing list PyGreSQL@vex.net https://mail.vex.net/mailman/listinfo/pygresql