Re: Server Freezing

From: Denis Lussier <denis(dot)lussier(at)enterprisedb(dot)com>
To: Waldomiro <waldomiro(at)shx(dot)com(dot)br>, pgsql-performance(at)postgresql(dot)org
Subject: Re: Server Freezing
Date: 2009-11-30 17:12:21
Message-ID: ba8cf61c0911300912q7f8efb43i75428e6f0a674627@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

Perhaps making your select be explicitely part of a read-only
transaction rather than letting java make use of an implicit
transaction (which may be in auto commit mode)

On 11/30/09, Waldomiro <waldomiro(at)shx(dot)com(dot)br> wrote:
> Hi everybody,
>
> I have an java application like this:
>
> while ( true ) {
> Thread.sleep( 1000 ) // sleeps 1 second
>
> SELECT field1
> FROM TABLE1
> WHERE field2 = '10'
>
> if ( field1 != null ) {
> BEGIN;
>
> processSomething( field1 );
>
> UPDATE TABLE1
> SET field2 = '20'
> WHERE field1 = '10';
>
> COMMIT;
> }
> }
>
> This is a simple program which is waiting for a record inserted by
> another workstation, after I process that record I update to an
> processed status.
>
> That table receives about 3000 inserts and 60000 updates each day, but
> at night I do a TRUNCATE TABLE1 (Every Night), so the table is very
> small. There is an index by field1 too.
>
> Some days It works very good all day, but somedays I have 7 seconds
> freeze, I mean, my serves delays 7 seconds on this statement:
> SELECT field1
> FROM TABLE1
> WHERE field2 = '10'
>
> Last Friday, It happens about 4 times, one at 9:50 am, another on 13:14
> pm, another on 17:27 pm and another on 17:57 pm.
>
> I looked up to the statistics for that table, but the statistics says
> that postgres is reading memory, not disk, becouse the table is very
> small and I do a select every second, so the postgres keeps the table in
> shared buffers.
>
> Why this 7 seconds delay? How could I figure out what is happening?
>
> I know:
>
> It is not disk, becouse statistics shows its reading memory.
> It is not internet delay, becouse it is a local network
> It is not workstations, becouse there are 2 workstations, and both
> freeze at the same time
> It is not processors, becouse my server has 8 processors
> It is not memory, becouse my server has 32 GB, and about 200 MB free
> It is not another big process or maybe not, becouse I think postgres
> would not stops my simples process for 7 seconds to do a big process,
> and I cant see any big process at that time.
> Its not lock, becouse the simple select freezes, It doesnot have an "FOR
> UPDATE"
> Its not a vaccum needed, becouse I do a TRUNCATE every night.
>
> Is It possible the checkpoint is doing that? Or the archiving? How can I
> see?
>
> Someone have any idea?
>
> Thank you
>
> Waldomiro Caraiani
>
> --
> Sent via pgsql-performance mailing list (pgsql-performance(at)postgresql(dot)org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-performance
>

In response to

Browse pgsql-performance by date

  From Date Subject
Next Message Craig James 2009-11-30 18:50:17 truncate in transaction blocks read access
Previous Message Laurent Laborde 2009-11-30 16:54:03 Cost of sort/order by not estimated by the query planner