From: | Heikki Linnakangas <hlinnaka(at)iki(dot)fi> |
---|---|
To: | Fabien COELHO <coelho(at)cri(dot)ensmp(dot)fr>, David Steele <david(at)pgmasters(dot)net> |
Cc: | Alvaro Herrera <alvherre(at)2ndquadrant(dot)com>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Andres Freund <andres(at)anarazel(dot)de>, Jeevan Ladhe <jeevan(dot)ladhe(at)enterprisedb(dot)com>, Dilip Kumar <dilipbalaut(at)gmail(dot)com>, PostgreSQL Developers <pgsql-hackers(at)lists(dot)postgresql(dot)org> |
Subject: | Re: pgbench - refactor init functions with buffers |
Date: | 2020-09-30 07:59:30 |
Message-ID: | 4522fb77-de4f-6357-725c-66ce9f012f73@iki.fi |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On 09/07/2020 10:05, Fabien COELHO wrote:
>> in favor of *PQExpBuffer().
>
> Attached v7 is rebased v5 which uses PQExpBuffer, per cfbot.
Thanks! I pushed this with small changes:
- I left out the changes to executeStatement(). I'm not quite convinced
it's a good idea or worth it, and it's unrelated to the main part of
this patch, so let's handle that separately.
- I also left out changes to use the C99-style "for (int i = 0; ...)"
construct. I think that's a good change for readability, but again
unrelated to this and hardly worth changing existing code for.
- I inlined the append_tablespace() function back to the callers. And I
did the same to the append_fillfactor() function, too. It seems more
readable to just call appendPQExpBuffer() diretly, than encapulate the
single appendPQExpBuffer() call in a helper function.
> @@ -3880,15 +3868,16 @@ initGenerateDataClientSide(PGconn *con)
>
> INSTR_TIME_SET_CURRENT(start);
>
> + /* printf overheads should probably be avoided... */
> for (k = 0; k < (int64) naccounts * scale; k++)
> {
> int64 j = k + 1;
>
> /* "filler" column defaults to blank padded empty string */
> - snprintf(sql, sizeof(sql),
> - INT64_FORMAT "\t" INT64_FORMAT "\t%d\t\n",
> - j, k / naccounts + 1, 0);
> - if (PQputline(con, sql))
> + printfPQExpBuffer(&sql,
> + INT64_FORMAT "\t" INT64_FORMAT "\t%d\t\n",
> + j, k / naccounts + 1, 0);
> + if (PQputline(con, sql.data))
> {
> pg_log_fatal("PQputline failed");
> exit(1);
Can you elaborate what you meant by the new "print overheads should
probably be avoided" comment? I left that out since it seems unrelated
to switching to PQExpBuffer.
- Heikki
From | Date | Subject | |
---|---|---|---|
Next Message | Craig Ringer | 2020-09-30 08:23:02 | PoC patch: expose TCP socket stats for walsenders |
Previous Message | Greg Nancarrow | 2020-09-30 07:57:05 | Re: Libpq support to connect to standby server as priority |