Tema: Re: Need nuomonės iš šono - DB
Autorius: Domas Mituzas
Data: 2011-12-10 04:26:00
> Čia jau v1.1? innodb-flush-log-at-trx-commit=2?

5.1.52-fb, jo, flush-log=2 - idant butu panasiau i MyISAM'a

> Net susigundžiau tiesiog naive (turimas hw, prielaidos)
> paeksperimentuoti su įvairiais galimais scenarijais, tačiau mysqlslap
> tiesiog mirtinai lužta (win32).
> Shit...

už kodo kokibe nepikit, buvau jetlagintas ir skubėjau, tad pasinaudojau 
copipastom

#!/usr/local/bin/python

import _mysql
import MySQLdb.constants.CLIENT as CL
import os

x = _mysql.connect("localhost","qbench", client_flag=CL.MULTI_STATEMENTS 
| CL.MULTI_RESULTS)
pid = os.getpid()

while True:
   x.query("UPDATE qb.que SET worker=%d WHERE worker is NULL LIMIT 1; 
SELECT id FROM qb.que WHERE worker=%d INTO @meh; DELETE FROM qb.que 
WHERE id=@meh" % ( pid, pid) )
   while True:
     r = x.store_result()
     if not r:
       if x.next_result() < 0:
          break
       else:
          continue

#!/usr/local/bin/python

import _mysql
import MySQLdb.constants.CLIENT as CL
import os

x = _mysql.connect("localhost","qbench", client_flag=CL.MULTI_STATEMENTS 
| CL.MULTI_RESULTS)
pid = os.getpid()

while True:
   x.query("LOCK TABLES qb.que WRITE; SELECT id FROM qb.que LIMIT 1 INTO 
@meh ; DELETE FROM qb.que WHERE id=@meh; UNLOCK TABLES")
   while True:
     r = x.store_result()
     if not r:
       if x.next_result() < 0:
          break
       else:
          continue


#!/usr/local/bin/python

import _mysql
import MySQLdb.constants.CLIENT as CL

x = _mysql.connect("localhost","qbench", client_flag=CL.MULTI_STATEMENTS 
| CL.MULTI_RESULTS)

while True:
   x.query("BEGIN; SELECT id FROM qb.que ORDER BY id LIMIT 1 INTO @meh 
FOR UPDATE; DELETE FROM qb.que WHERE id=@meh LIMIT 1; COMMIT")
   while True:
     r = x.store_result()
     if not r:
       if x.next_result() < 0:
          break
       else:
          continue

#!/usr/local/bin/python

import _mysql
import MySQLdb.constants.CLIENT as CL

x = _mysql.connect("localhost","qbench", client_flag=CL.MULTI_STATEMENTS 
| CL.MULTI_RESULTS)

while True:
   x.query("BEGIN; SELECT id FROM qb.que ORDER BY id LIMIT 1 INTO @meh 
FOR UPDATE; DELETE FROM qb.que WHERE id=@meh LIMIT 1; COMMIT")
   while True:
     r = x.store_result()
     if not r:
       if x.next_result() < 0:
          break
       else:
          continue
[root@udb8453.snc1 ~/qbench]# cat inserter.py
#!/usr/local/bin/python

import _mysql

x = _mysql.connect("localhost","qbench")


while True:
   x.query("INSERT INTO qb.que (data) VALUES 
('sadasdaslkjdaskljdaskljdaskljd')")