11

I am trying to use MySQL benchmark to test some queries. But, I am running to an error.

SELECT benchmark (10000, (select title from user));

and in return I get this error;

ERROR 1242 (21000): Subquery returns more than 1 row

Does anyone know how to benchmark a query?

Thanks

OMG Ponies
  • 325,700
  • 82
  • 523
  • 502
user239756
  • 113
  • 1
  • 1
  • 4

3 Answers3

11
select title from user

This returns multiple rows, which won't work.

Refer to this link: http://dev.mysql.com/doc/refman/5.0/en/information-functions.html#function_benchmark

The expression you pass must return a scalar result.

You need to change the query such that it returns a single row: ex:

select title from user where user_name = 'some_user'
dcp
  • 54,410
  • 22
  • 144
  • 164
11

you can use the mysqlslap utility to benchmark queries, see: http://dev.mysql.com/doc/refman/5.1/en/mysqlslap.html

Roland Bouman
  • 31,125
  • 6
  • 66
  • 67
-1

From http://dev.mysql.com/doc/refman/5.0/en/information-functions.html#function_benchmark

Only scalar expressions can be used. Although the expression can be a subquery, it must return a single column and at most a single row. For example, BENCHMARK(10, (SELECT * FROM t)) will fail if the table t has more than one column or more than one row.

Try

SELECT BENCHMARK(10000, (SELECT title FROM user LIMIT 1));
Mez
  • 24,430
  • 14
  • 71
  • 93
  • 3
    Note: While that does fix the error, it's not actually going to help him benchmark the query he wants to test. – Mark Byers Dec 28 '09 at 19:47