Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Postgres individual inserts, slow performance, delay

142 views
Skip to first unread message

John Mudd

unread,
Apr 13, 2013, 9:46:30 AM4/13/13
to
I'm just trying to insert a couple of rows. I need them committed right away. And there will be a brief delay before the next inserts are ready.

Sample python program:
http://pastebin.com/82NKnH99

I simulate the delay in my sample program by sleeping for 0.2 sec. You can see by the output that sometime the inserts are fast and sometimes close to 0.2 sec.

Output:
Elapsed: 0.0045 sec
Elapsed: 0.0046 sec
Elapsed: 0.1952 sec <-- slow
Elapsed: 0.0021 sec
Elapsed: 0.0012 sec
Elapsed: 0.1955 sec <-- slow
Elapsed: 0.1997 sec <-- slow
Elapsed: 0.0013 sec

If I sleep less than 0.2 sec then all inserts run relatively fast, around 1.5 ms, which is fine for the application.

If I sleep more than 0.2 sec (e.g. 1.0 sec) then all inserts take 0.2 sec.

Is there something I can change so that inserts are fast even with delays between inserts?

John

John Mudd

unread,
Apr 14, 2013, 12:28:35 AM4/14/13
to
I updated the link to a much shorter sample program. Still reproduces the problem.

John

John Mudd

unread,
Apr 14, 2013, 6:51:27 PM4/14/13
to
I think the "problem" is not slow INSERTs but "slow" transactions. I use quotes because it's not a true problem with Postgres. The real problem is with my expectations.

I see the same sort of delays when using SQLite. Here's a link to their documentation which probably applies to any db.

http://www.sqlite.org/faq.html#q19

John
0 new messages