Bluehost.com Web Hosting $6.95

unwanted insert delay

This is a discussion on unwanted insert delay within the MySQL Database forums, part of the Database Forums category; Hi, I am doing an INSERT (not delayed) query with C API, then starting another program thread, the thread reads ...


Go Back   Usenet Forums > Database Forums > MySQL Database

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 05-28-2007
Tobias Bergmann
 
Posts: n/a
Default unwanted insert delay

Hi,

I am doing an INSERT (not delayed) query with C API, then starting
another program thread, the thread reads the data that was just inserted
with a SELECT query via C Api.

This worked fine as long as there is just one thread running.

With 2 threats it sometimes happens that the data is not there in that
short time.

Inserting a delay of 1 second before the SELECT query solves the problem
for now.

But actually I don't do an "INSERT DELAYED" and wonder why the data is
not there immediately.

I read that an insert waits until no more selects are running but that
should cause a delay when doing the "INSERT" query

Does the C Api not wait for an insert to be finished?


Reply With Quote
  #2 (permalink)  
Old 05-29-2007
lark
 
Posts: n/a
Default Re: unwanted insert delay

Tobias Bergmann wrote:
> Hi,
>
> I am doing an INSERT (not delayed) query with C API, then starting
> another program thread, the thread reads the data that was just inserted
> with a SELECT query via C Api.
>
> This worked fine as long as there is just one thread running.
>
> With 2 threats it sometimes happens that the data is not there in that
> short time.
>
> Inserting a delay of 1 second before the SELECT query solves the problem
> for now.
>
> But actually I don't do an "INSERT DELAYED" and wonder why the data is
> not there immediately.
>
> I read that an insert waits until no more selects are running but that
> should cause a delay when doing the "INSERT" query
>
> Does the C Api not wait for an insert to be finished?
>
>


myisam tables use table level locking. so if you're doing an insert, the
table will be locked for the duration of the insert (no matter how short
that period may be). once the lock is removed, any other statements can
be executed against that table. table level locking has limitations and
this is one of those limitations. now, you can convert your table to
innodb and utilize what is called row-level locking where you can insert
as many records as you like and the engine won't lock the rest of your
rows while it's inserting new rows.

you also need to look at isolation levels which is specified in the .cnf
or .ini file by the statement transaction-isolation.

hope this helps.
Reply With Quote
  #3 (permalink)  
Old 06-07-2007
christopher@dailycrossword.com
 
Posts: n/a
Default Re: unwanted insert delay

I have to say, using a database to synchronize data between 2 programs
has more problems than the one you illustrated. A database is for
storing data, IMHO, not transferring from one user to another.

Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT +1. The time now is 06:59 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0