All pages
Powered by GitBook
1 of 1

Loading...

Query Limits and Timeouts

This article describes the different methods MariaDB provides to limit/timeout a query:

LIMIT

The LIMIT clause restricts the number of returned rows.

Stops the query after 'rows_limit' number of rows have been examined.

sql_safe_updates

If the variable is set, one can't execute an or statement unless one specifies a key constraint in the WHERE clause or provide a LIMIT clause (or both).

sql_select_limit

acts as an automatic LIMIT row_count to any query.

The above is the same as:

max_join_size

If the variable (also called sql_max_join_size) is set, then it will limit any SELECT statements that probably need to examine more thanMAX_JOIN_SIZE rows.

max_statement_time

If the variable is set, any query (excluding stored procedures) taking longer than the value of max_statement_time (specified in seconds) to execute will be aborted. This can be set globally, by session, as well as per user and per query. See .

See Also

  • variable

This page is licensed: CC BY-SA / Gnu FDL

SELECT ... LIMIT row_count
OR
SELECT ... LIMIT OFFSET, row_count
OR
SELECT ... LIMIT row_count OFFSET OFFSET
LIMIT ROWS EXAMINED
sql_safe_updates
UPDATE
DELETE
sql_select_limit
SELECT
max_join_size
max_statement_time
Aborting statements that take longer than a certain time to execute
WAIT and NOWAIT
Aborting statements that take longer than a certain time to execute
lock_wait_timeout
SELECT ... LIMIT ROWS EXAMINED rows_limit;
SET @@SQL_SAFE_UPDATES=1
UPDATE tbl_name SET not_key_column=val;
-> ERROR 1175 (HY000): You are using safe update mode 
  and you tried to update a table without a WHERE that uses a KEY column
SET @@SQL_SELECT_LIMIT=1000
SELECT * FROM big_table;
SELECT * FROM big_table LIMIT 1000;
SET @@MAX_JOIN_SIZE=1000;
->ERROR 1104 (42000): The SELECT would examine more than MAX_JOIN_SIZE ROWS; 
SELECT COUNT(null_column) FROM big_table;
  CHECK your WHERE AND USE SET SQL_BIG_SELECTS=1 OR SET MAX_JOIN_SIZE=# IF the SELECT IS okay