From: | Mario Splivalo <mario(dot)splivalo(at)mobart(dot)hr> |
---|---|
To: | PFC <lists(at)peufeu(dot)com> |
Cc: | Achilleus Mantzios <achill(at)matrix(dot)gatewaynet(dot)com>, pgsql-sql(at)postgresql(dot)org |
Subject: | Re: 'locking' the SELECTs based on indices... |
Date: | 2006-02-23 20:07:58 |
Message-ID: | 1140725278.5002.70.camel@localhost.localdomain |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
On Thu, 2006-02-23 at 17:35 +0100, PFC wrote:
>
> > Now, If some other user want's his prize, when checking his code, if he
> > sends code for some other service then service 1, that's ok. If he's
> > sends code for the service 1 the PERFORM will wait untill I'm finished
> > with previous user.
>
> Sorry for the double post.
>
> If the rows in your table represent associations between codes and
> services that are one-use only, you could simply use UPDATE or DELETE, to
> mark the row in question as having been "consumed".
> Then, you check how many rows were deleted or updated. If it's 1, good.
> If it's 0, the code has been used already.
>
> If the code itself is one-use only, you should have a codes table and a
> codes_to_services table, with an ON DELETE CASCADE so that, when you use a
> code, you delete it from the codes table and it's "consumed" for all
> services.
Thank you for the advice, I'll consider it too.
The original idea was with UPDATE, so I could mark codes wich are used,
but the table with codes will have 10M rows in the begining, for just
one game. Later we'll have more games, with like 100M rows in the table.
UPDATEing such table, when the server is under normal load (server also
hosts some other games) is between 15 and 40 seconds. That is why I
tried to eliminate UPDATEs and go with two tables, and INSERTS into the
second table, for used codes.
Mike
From | Date | Subject | |
---|---|---|---|
Next Message | Kashmira Patel (kupatel) | 2006-02-23 21:44:43 | Question about index scan vs seq scan when using count() |
Previous Message | Daniel Hernandez | 2006-02-23 19:03:03 | Re: Sum If |