Subject | Re: Either update conflict or count slow - Cant implement mail functionality |
---|---|
Author | Ali Gökçen |
Post date | 2004-05-27T16:20:07Z |
Hi,
Try this:
balance table:
RECID USERID countertype counter
1 90 'TOTALNEW' 12
2 90 'TOTALOLD' 1789
3 90 'NEW' 1
4 90 'NEW' 1
5 90 'OLD' 1
6 90 'OLD' 1
7 90 'NEW' 1
(i prefer to use numeric flags instead of string flags)
here is newmail status:
select sum(counter) as TOTAL_NEW from balance where countertype in
('NEW','TOTALNEW') where userid=90
insert new record with id 8 and userid 90 //
commit;
if(success) start to cleaning operation...
select count('NEW') AS NEWRECS where id <=8
update balance set counter=counter+NEWRECS where
countertype='TOTALNEW' and userid=90;
delete from balance where countertype='NEW' and USERID=90 and id<=8
commit;
if(not success) rollback; // dont wory, give a chance for next time
this technique will keep small your balance table without locks.
Note: you can write cleaning procedure to minimize client coding.
Regards.
Ali
--- In firebird-support@yahoogroups.com, "GOVINDKRISHNA"
<gkrishna@j...> wrote:
downloaded.
logs in, it should not show this popup. If the client is running and
a new mail is downloaded it should again pop up a message
there was a number it would popup and reset it to 0. This lead to
some pesky random update conflicts which was traced down to this.
for each downloaded mail and then do a count - display and delete
those records so the update conflict problem went away. But count is
becoming very slow. (Many Many users mail are stored in the same
database so the count has a where condition on userid)
Try this:
balance table:
RECID USERID countertype counter
1 90 'TOTALNEW' 12
2 90 'TOTALOLD' 1789
3 90 'NEW' 1
4 90 'NEW' 1
5 90 'OLD' 1
6 90 'OLD' 1
7 90 'NEW' 1
(i prefer to use numeric flags instead of string flags)
here is newmail status:
select sum(counter) as TOTAL_NEW from balance where countertype in
('NEW','TOTALNEW') where userid=90
insert new record with id 8 and userid 90 //
commit;
if(success) start to cleaning operation...
select count('NEW') AS NEWRECS where id <=8
update balance set counter=counter+NEWRECS where
countertype='TOTALNEW' and userid=90;
delete from balance where countertype='NEW' and USERID=90 and id<=8
commit;
if(not success) rollback; // dont wory, give a chance for next time
this technique will keep small your balance table without locks.
Note: you can write cleaning procedure to minimize client coding.
Regards.
Ali
--- In firebird-support@yahoogroups.com, "GOVINDKRISHNA"
<gkrishna@j...> wrote:
> Hello list,database. It should keep track of how many mails have been
>
> I need to implement the following functionality.
>
> There is an appserver downloading mail and storing it in a
downloaded.
> When the client connects to the database I want to show one ofthose popups saying "you have :N new mails". After that if the user
logs in, it should not show this popup. If the client is running and
a new mail is downloaded it should again pop up a message
>downloaded. The client used to check on startup and a timer tick. If
> Tried creating a record and updating it each time a mail was
there was a number it would popup and reset it to 0. This lead to
some pesky random update conflicts which was traced down to this.
>keeping track of stock etc. And so I switched to inserting a record
> So lurking on this list I read some mails which was talking about
for each downloaded mail and then do a count - display and delete
those records so the update conflict problem went away. But count is
becoming very slow. (Many Many users mail are stored in the same
database so the count has a where condition on userid)
>etc. Count is dead slow.
> Also we need to find out number of mails in a particular folder
>tblMessageFolderRelation which has MessageID and FolderID.
> So What is the best way to do something like this in Firebird.
>
>
> The data structure is like this.
> I have table tblMessages which has all message. A
> I want to display number of message in each folder. Best way to dothis.
>
>
> gk
>
>
>
> >>> This mail is created in Hamsa (www.jlmatrix.com) <<<