-
Notifications
You must be signed in to change notification settings - Fork 24
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support binary data #37
Comments
I understand what you want. While your code demonstrates the idea, it is certainly not fit to be included in luapgsql in this form.
Do you have any numbers or benchmarks that back this claim? |
I guess the correct solution would be to use |
Exactly. getvalue() and __index() could check the type, and somehow execParams must accept whether to accept binary results or not. And this is the hard part...
|
Why shouldn't it always be binary?
|
In many cases, binary data can actually be larger, I think. E.g. numbers with less digits than 8, small strings etc. I first want to see some figures to see if binary results are actually significantly faster before hacking that up. And then, execParams() would beed a change that is incompatible with previous versions if we had to support a „binary results“ flag. I’d rather avoid that, if possible. |
This simple benchmark
Gives results in milliseconds. The lesser the better:
That is, |
Maybe we need a control function on the connection object, e.g. conn:requestBinaryResults(boolean)? |
@mbalmer , may be. Imho, this is just a codding style. |
I discussed this on IRC with @daurnimator, we bot think the best solution is to keep the current function signature, but slightly extend it: The arguments to execParams and friends are normall the SQL statetement followed by the parameters. If we extend that so that the parameters can be passed as a table, then a after that table a boolean can passed as third argument, indicating binary or text. res = db:execParams('select ... $1 ..., $2 ...', a, b) or then new form res = db:execParams('select ... $1 ..., $2 ...', {a, b}) -- default to text then request binary results: res = db:execParams('select ... $1 ..., $2 ...', {a, b}, true) |
I'm not so sure any more.... -- by default it returns text for compat
db:returnStyle("text")
db:returnStyle("binary") -- now always returns binary
db:returnStyle("arg") -- now 3rd arg of execParams is "text" vs "binary"
db:returnStyle(nil) -- set back to default |
and yes, I think the binary indication should be part of the command execution functions, not a switch. and the way I proposed (table plus boolean) is easy to implement and remains compatible with the current API. |
It will be very usefull if you would add support binary data to retrieve, for instance, number values.
I found the code below useful for me.
In this case I use getvalue_binary to retrieve
long long
value from database. It is needed to add support for simple int, float, double values, etc. This is just a scatch. Futher more, updatestatic int conn_execParams(lua_State *L)
method. I have not a lot of time to unserstand how you feed the data to this method.use
instead of
and
An example of usage:
For small amount of rows it doesn't matter to use binary of text data. But for a lot of tons of content it can give emprovment.
The text was updated successfully, but these errors were encountered: