Now lets get to generate some queries, we use a YACC-style based grammar file know as a RQG grammar file. This grammar file defines a set of rules, lets understand this further with an example:
Looking into file conf/examples/example.yy, we can see
query:
update | insert | delete ;
update:
UPDATE _table SET _field = digit WHERE condition LIMIT _digit ;
delete:
DELETE FROM _table WHERE condition LIMIT _digit ;
insert:
INSERT INTO _table ( _field ) VALUES ( _digit ) ;
condition:
_field < digit | _field = _digit ;
Rules:
query, update, delete , condition are called rules, which define the structure for the queries.
In-built-identifiers:
_table, _field, _digit, they are ways to access a random table, column, and data from the data that has been generated.
query:
This is the rule which defines the flow for a query, i.e.:
query:
update | insert | delete ;
means either a update or insert or delete is chosen and that respective rule is blow up, and this is purely random. This way a query a random query is generated, i.e. one query at a time until the no of queries are generated or the execution duration is reached.
perl server.pl --baseidr=$MYSQL_SOURCE
perl gendata.pl --dsn=dbi:mysql:host=127.0.0.1:port=19300:user=root:database=test --spec=conf/examples/example.zz
perl gensql.pl --dsn=dbi:mysql:host=127.0.0.1:port=19300:user=root:database=test --grammar=conf/examples/example.yy --queries=5
# 2013-11-10T15:47:59 Using Log::Log4perl
# 2013-11-10T15:47:59 Caching schema metadata for dbi:mysql:host=127.0.0.1:port=19300:user=root:database=test
INSERT INTO `table100_key_pk_parts_2_int_autoinc` ( `col_set_utf8_key_default_null` ) VALUES ( 3 );
INSERT INTO `table1_key_pk_parts_2_int_autoinc` ( `col_set_latin1` ) VALUES ( 3 );
DELETE FROM `table0_key_pk_parts_2_int_autoinc` WHERE `col_enum_latin1_key_default_null` < 7 LIMIT 9;
INSERT INTO `table10_key_pk_parts_2_int_autoinc` ( `col_int_unsigned_key` ) VALUES ( 7 );
DELETE FROM `table10_key_pk_parts_2_int_autoinc` WHERE `col_char_utf8_default_null` < 0 LIMIT 4;
If the above steps are too many, try the below simple command line:
perl runall.pl --basedir=$MYSQL_SOURCE --grammar=conf/examples/example.yy --gendata=conf/examples/example.zz --queries=5 --sqltrace --threads=1
The above command line will start the server load data and generate 5 queries, the one this you may notice different in the options is --threads and this is some thing we will discuss later but for now --threads=1 means one instance of the MySQL client which executes the above queries against the MySQL Server.
Another interesting option you may notice is --sqltrace, this options goes about printing the queries on standard output you can try without --sqltrace and see if makes a difference.
Looking into file conf/examples/example.yy, we can see
query:
update | insert | delete ;
update:
UPDATE _table SET _field = digit WHERE condition LIMIT _digit ;
delete:
DELETE FROM _table WHERE condition LIMIT _digit ;
insert:
INSERT INTO _table ( _field ) VALUES ( _digit ) ;
condition:
_field < digit | _field = _digit ;
Rules:
query, update, delete , condition are called rules, which define the structure for the queries.
In-built-identifiers:
_table, _field, _digit, they are ways to access a random table, column, and data from the data that has been generated.
query:
This is the rule which defines the flow for a query, i.e.:
query:
update | insert | delete ;
means either a update or insert or delete is chosen and that respective rule is blow up, and this is purely random. This way a query a random query is generated, i.e. one query at a time until the no of queries are generated or the execution duration is reached.
perl server.pl --baseidr=$MYSQL_SOURCE
perl gendata.pl --dsn=dbi:mysql:host=127.0.0.1:port=19300:user=root:database=test --spec=conf/examples/example.zz
perl gensql.pl --dsn=dbi:mysql:host=127.0.0.1:port=19300:user=root:database=test --grammar=conf/examples/example.yy --queries=5
# 2013-11-10T15:47:59 Using Log::Log4perl
# 2013-11-10T15:47:59 Caching schema metadata for dbi:mysql:host=127.0.0.1:port=19300:user=root:database=test
INSERT INTO `table100_key_pk_parts_2_int_autoinc` ( `col_set_utf8_key_default_null` ) VALUES ( 3 );
INSERT INTO `table1_key_pk_parts_2_int_autoinc` ( `col_set_latin1` ) VALUES ( 3 );
DELETE FROM `table0_key_pk_parts_2_int_autoinc` WHERE `col_enum_latin1_key_default_null` < 7 LIMIT 9;
INSERT INTO `table10_key_pk_parts_2_int_autoinc` ( `col_int_unsigned_key` ) VALUES ( 7 );
DELETE FROM `table10_key_pk_parts_2_int_autoinc` WHERE `col_char_utf8_default_null` < 0 LIMIT 4;
If the above steps are too many, try the below simple command line:
perl runall.pl --basedir=$MYSQL_SOURCE --grammar=conf/examples/example.yy --gendata=conf/examples/example.zz --queries=5 --sqltrace --threads=1
The above command line will start the server load data and generate 5 queries, the one this you may notice different in the options is --threads and this is some thing we will discuss later but for now --threads=1 means one instance of the MySQL client which executes the above queries against the MySQL Server.
Another interesting option you may notice is --sqltrace, this options goes about printing the queries on standard output you can try without --sqltrace and see if makes a difference.
No comments:
Post a Comment