Professional Web Applications Themes

unwanted insert delay - MySQL

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 ...

  1. #1

    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?


    Tobias Guest

  2. #2

    Default Re: unwanted insert delay

    Tobias Bergmann wrote: 

    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.
    lark Guest

  3. #3

    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.

    christopher@dailycrossword.com Guest

Similar Threads

  1. Question Insert from ASP to SQL using recordset data as values in insert statement
    By JasonM in forum Microsoft SQL / MS SQL Server
    Replies: 0
    Last Post: June 13th, 05:54 PM
  2. Insert/Update delay in shared environment
    By scaldwell in forum Coldfusion Database Access
    Replies: 2
    Last Post: March 22nd, 05:08 PM
  3. unwanted delay to later frames
    By philippe in forum Macromedia Flash
    Replies: 0
    Last Post: May 12th, 11:43 AM
  4. Replies: 3
    Last Post: September 30th, 09:24 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139