[erlang-questions] ODBC 160 times slower thatn pgsql - is it normal?

Sergey S. <>
Mon Sep 8 17:52:19 CEST 2008


Hello.

I've wrote simple benchmark, in order to test ODBC and pgsql drivers. I got
very strange results, saying that ODBC 160 times slower than pgsql:

[pgsql_bm] runtime = 50, wall_clock = 144

[odbc_bm] runtime = 0, wall_clock = 8009

There might be my mistake in odbc.ini/odbcinst.ini or smth else, so I'm
writting this letter. Is it normal that ODBC works too slow?

The code used:

------------------------------------

odbc_bm() ->
    odbc:start(),
    {ok, Ref} = odbc:connect("DSN=PostgreSQL", []),
    benchmark("odbc_bm",
                     fun() -> odbc:sql_query(Ref, "INSERT INTO foo (bar)
VALUES (123)") end,
                     200),
    odbc:stop().

pgsql_bm() ->
    {ok, Db} = pgsql:connect("localhost", "gin", "gin", ""),
    benchmark("pgsql_bm",
                     fun() -> pgsql:squery(Db, "INSERT INTO foo (bar) VALUES
(123)") end,
                     200),
    pgsql:terminate(Db).

benchmark(Title, Fun, Times) ->
    statistics(runtime),
    statistics(wall_clock),
    for(1, Times, Fun),
    {_, Runtime} = statistics(runtime),
    {_, Wallclock} = statistics(wall_clock),

for(I, Max, _) when I > Max ->
    ok;
for(I, Max, F) ->
    F(),
    for(I+1, Max, F).

------------------------------------

Additional information:
I use pgsql from ejabberd-modules package, erlang R12B.3, PostgreSQL 8.3.3,
unixodbc 2.2.12, psqlodbc 08.03.0200
OS: Archlinux current

odbc.ini:

[PostgreSQL]
Description     = foobar
Driver          = PostgreSQL
Database        = gin
Servername      = localhost
UserName        = sergey
Password        =

odbcinst.ini:

[PostgreSQL]
Description     = PostgreSQL driver
Driver = /usr/lib/psqlodbcw.so
Setup           = /usr/lib/libodbcpsqlS.so

--

Sergey
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20080908/f67765dc/attachment.html>


More information about the erlang-questions mailing list