Account Options

  1. Sign in
The old Google Groups will be going away soon.
Switch to the new Google Groups.
Google Groups Home
« Groups Home
Transaction use and performance issues
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  5 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Yves-Olivier Renault  
View profile  
 More options Jan 27 2011, 6:26 am
From: Yves-Olivier Renault <yorena...@gmail.com>
Date: Thu, 27 Jan 2011 03:26:36 -0800 (PST)
Local: Thurs, Jan 27 2011 6:26 am
Subject: Transaction use and performance issues
Hi,

I am using transactions to write data in a sqlite3 database. As noted
in the sqlite3 FAQ (http://www.sqlite.org/faq.html#q19), disk access
limitations do not enable to perform more than a few dozen
transactions per second.
To increase the performance of my writing operations, I started
grouping several put() statements inside a single transaction. As I
thought that put() was merely some INSERT statements, which are very
quick because no disk access, I expected the following code to write
my two storeable objects in one single transaction about as long as if
I had put only one object.

dba::Transaction* transaction = new dba::Transaction(_dbaArchive-

>createTransaction());

dba::SQLOStream ostream = transaction->getOStream();
ostream.put(myStoreableObject1);
ostream.put(myStoreableObject2);
delete transaction;

The above code takes about 100 ms to run. If I remove one of the
put(), only 50 ms. I have therefore no performance gain from grouping
the put() in a single transaction.
Did I misunderstand something about transactions? or does put() write
on the disk before committing?

Thanks
Yves-Olivier


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Lukasz Michalski  
View profile  
 More options Jan 27 2011, 7:25 am
From: Lukasz Michalski <l...@zork.pl>
Date: Thu, 27 Jan 2011 13:25:13 +0100
Local: Thurs, Jan 27 2011 7:25 am
Subject: Re: [Debea] Transaction use and performance issues

On 01/27/11 12:26, Yves-Olivier Renault wrote:

It sends couple of queries to get next id for object and then sends
inserts. All of this is enclosed in BEGIN...COMMIT statements. I cannot
say for sure if or when sqlite library performs disk operations.

You can recompile debea with DBA_QUERY_DEBUG=1 - it will log all queries
to stderr.

I think that you can archive big performance gain by replacing IdFetcher
with custom one. For example you can assign id from memory and store
last used id in database when application exits. This will remove 1
SELECT and 1 UPDATE per put().

See
http://debea.net/trac/browser/branches/debea_1_4/dba/dba/genericfetch...

This code is executed when new object is inserted to database.

Regards,
Łukasz

  signature.asc
< 1K Download

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Yves-Olivier Renault  
View profile  
 More options Jan 27 2011, 11:00 am
From: Yves-Olivier Renault <yorena...@gmail.com>
Date: Thu, 27 Jan 2011 17:00:00 +0100
Subject: Re: [Debea] Transaction use and performance issues

Thanks for your answer Łukasz. I used your compilation flag to list the
queries performed for one put() call if I use a custom id fetcher :

0xb53dbd0:BEGIN
0xb53dbd0:INSERT INTO level0_table (id) VALUES (275893)
0xb53dbd0:SELECT id FROM string_table WHERE strings_in_level0=275893
0xb53dbd0:INSERT INTO string_table
(id,string_key,string_value,strings_in_level0) VALUES
(275894,'Event','foo',275893)

Then I ran these queries one by one and found out that the most
time-consuming one was by far the SELECT. In my application each "level0"
object has a list of strings that are stored using a BIND_COL macro.
I don't really understand why the SELECT is needed? We just added the new id
in the level0_table and we still have to look for this id in the
string_table, why?

Regards,
Yves-Olivier

On 27 January 2011 13:25, Lukasz Michalski <l...@zork.pl> wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Lukasz Michalski  
View profile  
 More options Jan 28 2011, 3:50 am
From: Lukasz Michalski <l...@zork.pl>
Date: Fri, 28 Jan 2011 09:50:17 +0100
Local: Fri, Jan 28 2011 3:50 am
Subject: Re: [Debea] Transaction use and performance issues

On 01/27/11 17:00, Yves-Olivier Renault wrote:

You are about to store object with std::list mapped using BIND_COL. Lets
say that this is new_list.

Debea need to know which objects are deleted from new_list since last
put().

It is done by reading ids of all objects from database that were in
collection last time using SELECT to old_list.

All objects that exists in new_list are removed from old_list.

If there is anything left on old_list, then debea issues 'DELETE from
table WHERE id in ( old_list[0],...,old_list[n] )' to delete objects
that you removed from collection since last put().

This SELECT is indeed not needed if object that is parent to list is
about to be inserted.

Please add a ticket for this, I will try to look at serialization code
and see if I can optimize out this list comparison for new objects.

Regards,
Łukasz

  signature.asc
< 1K Download

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Yves-Olivier Renault  
View profile  
 More options Jan 28 2011, 4:09 am
From: Yves-Olivier Renault <yorena...@gmail.com>
Date: Fri, 28 Jan 2011 10:09:46 +0100
Local: Fri, Jan 28 2011 4:09 am
Subject: Re: [Debea] Transaction use and performance issues

OK, I wrote a ticket (#71 <http://debea.net/trac/ticket/71>)

I found a way to greatly enhance the performance of my code :
I created an index for the strings_in_level0 field in the string_table.

Thanks for the support

Regards
Yves-Olivier

On 28 January 2011 09:50, Lukasz Michalski <l...@zork.pl> wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »