public inbox for [email protected]  
help / color / mirror / Atom feed
PostgreSQL ODBC mylog() uses lots of CPU in INTEGER field SQL query
2+ messages / 2 participants
[nested] [flat]

* PostgreSQL ODBC mylog() uses lots of CPU in INTEGER field SQL query
@ 2021-05-07 18:13 Marko Ristola <[email protected]>
  2021-05-11 23:57 ` Re: PostgreSQL ODBC mylog() uses lots of CPU in INTEGER field SQL query Inoue,Hiroshi <[email protected]>
  0 siblings, 1 reply; 2+ messages in thread

From: Marko Ristola @ 2021-05-07 18:13 UTC (permalink / raw)
  To: pgsql-odbc

I did a query of 4 million rows into an INTEGER field.

Linux perf shows following profile (hottest functions):

   9.91%  bc_sqlselect  psqlodbcw.so               [.] mylog
   9.64%  bc_sqlselect  psqlodbcw.so               [.]
QR_read_a_tuple_from_db
   4.83%  bc_sqlselect  psqlodbcw.so               [.]
copy_and_convert_field
   4.57%  bc_sqlselect  libpthread-2.17.so         [.] pthread_mutex_unlock
   4.51%  bc_sqlselect  libpthread-2.17.so         [.] pthread_mutex_lock
   4.40%  bc_sqlselect  psqlodbcw.so               [.]
SOCK_get_next_n_bytes.part.2
   3.93%  bc_sqlselect  psqlodbcw.so               [.] PGAPI_ExtendedFetch

Following patch removes the only mylog() call (not a macro)

from the PostgreSQL ODBC driver from consuming CPU:

(MYLOG() macro is used to avoid the heavy mylog() call.)


diff --git a/results.c b/results.c
index 1f6a12c..ec89600 100644
--- a/results.c
+++ b/results.c
@@ -4632,7 +4632,6 @@ SC_pos_add(StatementClass *stmt,
                        goto cleanup;
                }
                MYLOG(0, "addstr=%s\n", addstr.data);
-               mylog("addstr=%s\n", addstr.data);
                s.qstmt->exec_start_row = s.qstmt->exec_end_row = s.irow;
                s.updyes = TRUE;
                ret = PGAPI_ExecDirect(hstmt, (SQLCHAR *) addstr.data,
SQL_NTS, 0);


Best Regards, Marko Ristola

--
Marko Ristola
Software developer
BC Platforms

m. +358 40 593 2182
e. [email protected]
w. www.bcplatforms.com


^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* Re: PostgreSQL ODBC mylog() uses lots of CPU in INTEGER field SQL query
  2021-05-07 18:13 PostgreSQL ODBC mylog() uses lots of CPU in INTEGER field SQL query Marko Ristola <[email protected]>
@ 2021-05-11 23:57 ` Inoue,Hiroshi <[email protected]>
  0 siblings, 0 replies; 2+ messages in thread

From: Inoue,Hiroshi @ 2021-05-11 23:57 UTC (permalink / raw)
  To: Marko Ristola <[email protected]>; +Cc: pgsql-odbc

Hi Marko,

I would take care of your patch.

Thanks.
Hiroshi Inoue

2021年5月8日(土) 4:31 Marko Ristola <[email protected]>:

> I did a query of 4 million rows into an INTEGER field.
>
> Linux perf shows following profile (hottest functions):
>
>    9.91%  bc_sqlselect  psqlodbcw.so               [.] mylog
>    9.64%  bc_sqlselect  psqlodbcw.so               [.]
> QR_read_a_tuple_from_db
>    4.83%  bc_sqlselect  psqlodbcw.so               [.]
> copy_and_convert_field
>    4.57%  bc_sqlselect  libpthread-2.17.so         [.]
> pthread_mutex_unlock
>    4.51%  bc_sqlselect  libpthread-2.17.so         [.] pthread_mutex_lock
>    4.40%  bc_sqlselect  psqlodbcw.so               [.]
> SOCK_get_next_n_bytes.part.2
>    3.93%  bc_sqlselect  psqlodbcw.so               [.] PGAPI_ExtendedFetch
>
> Following patch removes the only mylog() call (not a macro)
>
> from the PostgreSQL ODBC driver from consuming CPU:
>
> (MYLOG() macro is used to avoid the heavy mylog() call.)
>
>
> diff --git a/results.c b/results.c
> index 1f6a12c..ec89600 100644
> --- a/results.c
> +++ b/results.c
> @@ -4632,7 +4632,6 @@ SC_pos_add(StatementClass *stmt,
>                         goto cleanup;
>                 }
>                 MYLOG(0, "addstr=%s\n", addstr.data);
> -               mylog("addstr=%s\n", addstr.data);
>                 s.qstmt->exec_start_row = s.qstmt->exec_end_row = s.irow;
>                 s.updyes = TRUE;
>                 ret = PGAPI_ExecDirect(hstmt, (SQLCHAR *) addstr.data,
> SQL_NTS, 0);
>
>
> Best Regards, Marko Ristola
>
> --
> Marko Ristola
> Software developer
> BC Platforms
>
> m. +358 40 593 2182
> e. [email protected]
> w. www.bcplatforms.com
>


^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2021-05-11 23:57 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2021-05-07 18:13 PostgreSQL ODBC mylog() uses lots of CPU in INTEGER field SQL query Marko Ristola <[email protected]>
2021-05-11 23:57 ` Inoue,Hiroshi <[email protected]>

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox