-
Notifications
You must be signed in to change notification settings - Fork 22
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
Consider adding prepared statements #23
Comments
I'll consider adding them, but there are trade-offs:
If you're convinced this is substantially faster and can demonstrate some numbers (e.g. using hdbc-odbc?), I'll look into adding this to |
I ran some speed comparisons between odbc and hdbc and saw signifcant speed differences in favour of prepared statements. It's possible I messed this up somehow. Can you take a look? I inserted 100,000 rows with fairly large data using hdbc prepared statements Here is one run: |
Awesome! Could you link to a copy of your hdbcperf repo? I assume that the
number are legit but I’d like to see how the data is generated and timed to
confirm.
…On Tue, 17 Jul 2018 at 00:01, gbwey ***@***.***> wrote:
I ran some speed comparisons between odbc and hdbc and saw signifcant
speed differences in favour of prepared statements. It's possible I messed
this up somehow. Can you take a look?
Thanks,
I inserted 100,000 rows with fairly large data using
odbc TH
odbc plain
perf.zip <https://github.com/fpco/odbc/files/2199464/perf.zip>
hdbc prepared statements
hdbc raw
hdbc runraw
Each time I ran this, it showed prepared statements were faster by a
factor of at least two.
Here is one run:
16 17:17:49 D:\haskell\hdbcperf>stack exec hdbcperf r
create table OdbcTH
create table OdbcRaw
odbc TH starting ...
odbc TH: 141.39708733558655
odbc raw starting ...
odbc raw: 123.21104717254639
create table Prepared
create table Run
create table RunRaw
hdbc prepared starting ...
hdbc prepared: 53.47105836868286
hdbc run starting ...
hdbc run: 127.43228888511658
hdbc runraw starting ...
hdbc runraw: 74.92328548431396
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#23 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AAArC9-p2B35e2DQL9PyRGFVeBXnicKDks5uHQ0hgaJpZM4VQbKK>
.
|
There should not be, for example, any difference in speed between odbc TH
and manual construction, the former is just syntactic sugar for the latter,
indicating that you need something like criterion to get the real average.
…On Tue, 17 Jul 2018 at 09:02, Christopher Done ***@***.***> wrote:
Awesome! Could you link to a copy of your hdbcperf repo? I assume that the
number are legit but I’d like to see how the data is generated and timed to
confirm.
On Tue, 17 Jul 2018 at 00:01, gbwey ***@***.***> wrote:
> I ran some speed comparisons between odbc and hdbc and saw signifcant
> speed differences in favour of prepared statements. It's possible I messed
> this up somehow. Can you take a look?
> Thanks,
>
> I inserted 100,000 rows with fairly large data using
> odbc TH
> odbc plain
> perf.zip <https://github.com/fpco/odbc/files/2199464/perf.zip>
>
> hdbc prepared statements
> hdbc raw
> hdbc runraw
> Each time I ran this, it showed prepared statements were faster by a
> factor of at least two.
>
> Here is one run:
> 16 17:17:49 D:\haskell\hdbcperf>stack exec hdbcperf r
> create table OdbcTH
> create table OdbcRaw
> odbc TH starting ...
> odbc TH: 141.39708733558655
> odbc raw starting ...
> odbc raw: 123.21104717254639
> create table Prepared
> create table Run
> create table RunRaw
> hdbc prepared starting ...
> hdbc prepared: 53.47105836868286
> hdbc run starting ...
> hdbc run: 127.43228888511658
> hdbc runraw starting ...
> hdbc runraw: 74.92328548431396
>
> —
> You are receiving this because you commented.
> Reply to this email directly, view it on GitHub
> <#23 (comment)>, or mute
> the thread
> <https://github.com/notifications/unsubscribe-auth/AAArC9-p2B35e2DQL9PyRGFVeBXnicKDks5uHQ0hgaJpZM4VQbKK>
> .
>
|
I just pushed the repo hdbcperf which now uses criterion. The results are in results.txt |
Nice work, thanks! I've reviewed your numbers and code so far, and it seems that you've found the actual speed difference. If I add All HDBC connections set implicit transactions on by default, which explains that. We could add a It may still be that prepared statements are faster than regular statements, but if we're already as fast as or faster than HDBC with prepared statements, you may be happy with it like this. What do you think?
|
Here is a last benchmark which has just uses one commit at the very end to keep things consistent. I also added another table with 20 columns . I am seeing hdbc prepared gives around 50% improvement over odbc raw. Interesting is the bigger slow down by odbc TH with the 20 column inserts. |
I am using your stack repo which links to the same fork of hdbc-odbc from github (I saw it clone them), so we are using the exact same package versions and GHC version. My performance numbers don't match yours presently, odbc raw is still fastest: https://gist.github.com/chrisdone/6b3714808ea43326e72b85daedcd7492 I think if anything is different, it'll be our ODBC driver version and SQL Server version. What are yours? Mine are:
You appear to be using
I'm on Linux so I won't be able to reproduce your numbers with the native client, which I think was only available for Windows. Would you mind testing with the ODBC Driver? I'd be interested to see whether it's faster, or slower, and whether this affects the HDBC/ODBC speed difference. If the new driver is faster or slower, it would be worth noting in this package's README and Haddocks, and give a recommendation to users. Alternatively, it could be a mysterious Windows vs Linux difference. But I doubt that and more suspect the ODBC driver. Thanks for your patience and time spent on this issue. 👍 I think the work we're doing here will be useful for other people, too. |
I agree that this is very useful and I am quite happy to work on it. Running with odbc 13 didn't seem to make much difference. Here are the results I am using "ODBC Driver 13 for SQL Server" Next week I should be able to run these benchmarks using ubuntu (virtual box) which might give us more information. |
Ok, thanks, so the 13 driver doesn’t change anything. So I see two
differences:
* Driver 13 vs 17
* SQL Server 2012 vs 2017
Aside from Linux vs Windows these might cause the performance differences
between us.
I can try the 2013 driver version. But I can’t directly test that SQL
Server version, as it predates the free Docker releases by MS.
I can look into getting a copy of Windows to run in a VM.
The newer SQL Server 2017 may have new optimisations not present in the
2012 release. Just speculating here.
Anyway, in parallel I can take a look at adding prepared queries on a
branch and see how they perform on my system with the odbc package.
…On Fri, 20 Jul 2018 at 01:35, gbwey ***@***.***> wrote:
I agree that this is very useful and I am quite happy to work on it.
Running with odbc 13 didn't seem to make much difference. Here are the
results
<https://github.com/gbwey/hdbcperf/blob/master/results_odbcdriver2.txt>
I am using "ODBC Driver 13 for SQL Server"
Microsoft SQL Server 2012 (SP4) (KB4018073) - 11.0.7001.0 (X64)
Aug 15 2017 10:23:29
Copyright (c) Microsoft Corporation
Enterprise Edition (64-bit) on Windows NT 6.3 (Build 9600: ) (Hypervisor)
Next week I should be able to run these benchmarks using ubuntu (virtual
box) which might give us more information.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#23 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AAArC5tQoaLKJoXVBO26UlW-dZEdyrzGks5uIRe4gaJpZM4VQbKK>
.
|
I ran several benchmarks using ubuntu1604 with virtualbox (odbc 13 driver) and one with windows as a baseline. I ran them several times as the numbers were unexpected! Everything on ubuntu was really slow, except for these four exceptions (below), which approached windows speed:
So other than these cases, the benchmarks are so completely different from windows that I think something else is going on here. I added Comp.hs to help compare separate benchmarks using "mean". (eg dump fn1 fn2) There is one extra benchmark type with "hdbc ... commit" in the title that does a commit for each insert. Here are the results: |
Hi,
This is an excellent library. I would like to use this package instead
of hdbc-odbc but the only thing missing are prepared statements.
Is that something you are thinking of adding?
The text was updated successfully, but these errors were encountered: