SQL Keywords

SQL HIGH_PRIORITY

What does SQL HIGH_PRIORITY do in MySQL?

Adds a scheduling hint that lets a SELECT or INSERT run before conflicting lower-priority statements on the same MyISAM or MEMORY table in MySQL.
Sign up to get up to date news on SQL keywords
Welcome to the Galaxy, Guardian!
You'll be receiving a confirmation email

Follow us on twitter :)
Oops! Something went wrong while submitting the form.

Compatible dialects for SQL HIGH_PRIORITY: Supported: MySQL, MariaDB Ignored: InnoDB engine even inside MySQL/MariaDB Not supported: PostgreSQL, SQL Server, Oracle, SQLite, Standard SQL

SQL HIGH_PRIORITY Full Explanation

HIGH_PRIORITY is a MySQL-specific modifier that can be prefixed to SELECT or INSERT. It instructs the MySQL thread scheduler to execute that statement ahead of other waiting statements of normal priority that would otherwise block it due to table-level locks. For SELECT HIGH_PRIORITY: The query bypasses the default read-after-write queue and is executed before pending INSERT, UPDATE, or DELETE statements that require a write lock on the same table. It is only meaningful for storage engines that rely on table-level locking (MyISAM, MEMORY, MERGE). With row-level engines such as InnoDB, the modifier is accepted syntactically but has no effect because those engines do not wait for a global read lock.For INSERT HIGH_PRIORITY: The insert gains precedence over waiting SELECT statements that would normally be favored so readers are not starved. This modifier applies only to MyISAM and MEMORY tables. In other engines its presence is ignored.Because HIGH_PRIORITY can starve other sessions, use it sparingly and only when a short, time-critical query absolutely needs to complete first. The keyword does not override explicit locks issued by LOCK TABLES nor override transactions holding row locks in InnoDB. It is also not part of the SQL standard and is unsupported by most other databases.

SQL HIGH_PRIORITY Syntax

-- SELECT variant
SELECT HIGH_PRIORITY column_list
FROM table_name
WHERE conditions;

-- INSERT variant
INSERT HIGH_PRIORITY INTO table_name (col1, col2)
VALUES (val1, val2);

SQL HIGH_PRIORITY Parameters

Example Queries Using SQL HIGH_PRIORITY

-- Run an urgent read before queued writes
SELECT HIGH_PRIORITY id, email
FROM users
WHERE id = 123;

-- Allow a high-priority bulk insert during a reporting window
INSERT HIGH_PRIORITY INTO log_archive (event_time, event_type)
SELECT event_time, event_type
FROM live_log
WHERE event_date = CURDATE();

Expected Output Using SQL HIGH_PRIORITY

  • The selected rows are returned or the rows are inserted immediately, even if other sessions are waiting for locks on the same MyISAM/MEMORY table
  • In row-level engines no observable difference occurs

Use Cases with SQL HIGH_PRIORITY

  • Emergency diagnostics that must read a heavily written MyISAM table immediately.
  • High-frequency data ingestion where inserts should not be blocked by long-running reads.
  • Legacy systems still relying on table-level engines and suffering from lock contention.

Common Mistakes with SQL HIGH_PRIORITY

  • Expecting any effect on InnoDB tables.
  • Using HIGH_PRIORITY with UPDATE or DELETE (not allowed).
  • Assuming it works in PostgreSQL, SQL Server, Oracle, or SQLite.
  • Overusing it and starving other sessions of write access.

Related Topics

LOW_PRIORITY, DELAYED, LOCK TABLES, INSERT DELAYED, NOWAIT

First Introduced In

MySQL 3.22 (1998)

Frequently Asked Questions

Does HIGH_PRIORITY speed up every query?

No. It only changes the order in which the server grants locks on table-level engines. It does not change execution plans or I/O speed.

Will HIGH_PRIORITY help on InnoDB tables?

No. InnoDB relies on row-level locking so the keyword is ignored.

Can I combine HIGH_PRIORITY with LOW_PRIORITY?

No. A statement can have either HIGH_PRIORITY, LOW_PRIORITY, or neither, but not both.

Is HIGH_PRIORITY safe to use in production?

Yes, but sparingly. Overuse can starve other sessions and increase contention because writes or reads of lower priority may have to wait indefinitely.

Sign up to get up to date news on SQL keywords
Welcome to the Galaxy, Guardian!
You'll be receiving a confirmation email

Follow us on twitter :)
Oops! Something went wrong while submitting the form.
Trusted by top engineers on high-velocity teams
Aryeo Logo
Assort Health
Curri
Rubie Logo
Bauhealth Logo
Truvideo Logo

Check out other commonly used SQL Keywords!