aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/CHANGELOG.md
diff options
context:
space:
mode:
authorRyuta Kamizono <kamipo@gmail.com>2019-03-13 09:29:00 +0900
committerRyuta Kamizono <kamipo@gmail.com>2019-03-16 18:44:55 +0900
commit97347d8c409f14b682dd9ec52ded3c869d0ba479 (patch)
tree7baf7114da2ed0e305663085778267b6a3f06cb7 /activerecord/CHANGELOG.md
parent85984e50311b7138504abe1be9bbe99f96dde8ef (diff)
downloadrails-97347d8c409f14b682dd9ec52ded3c869d0ba479.tar.gz
rails-97347d8c409f14b682dd9ec52ded3c869d0ba479.tar.bz2
rails-97347d8c409f14b682dd9ec52ded3c869d0ba479.zip
Support Optimizer Hints
We as Arm Treasure Data are using Optimizer Hints with a monkey patch (https://gist.github.com/kamipo/4c8539f0ce4acf85075cf5a6b0d9712e), especially in order to use `MAX_EXECUTION_TIME` (refer #31129). Example: ```ruby class Job < ApplicationRecord default_scope { optimizer_hints("MAX_EXECUTION_TIME(50000) NO_INDEX_MERGE(jobs)") } end ``` Optimizer Hints is supported not only for MySQL but also for most databases (PostgreSQL on RDS, Oracle, SQL Server, etc), it is really helpful to turn heavy queries for large scale applications.
Diffstat (limited to 'activerecord/CHANGELOG.md')
-rw-r--r--activerecord/CHANGELOG.md25
1 files changed, 25 insertions, 0 deletions
diff --git a/activerecord/CHANGELOG.md b/activerecord/CHANGELOG.md
index 3d7508252a..148b3800a8 100644
--- a/activerecord/CHANGELOG.md
+++ b/activerecord/CHANGELOG.md
@@ -1,3 +1,28 @@
+* Support Optimizer Hints.
+
+ In most databases, there is a way to control the optimizer is by using optimizer hints,
+ which can be specified within individual statements.
+
+ Example (for MySQL):
+
+ Topic.optimizer_hints("MAX_EXECUTION_TIME(50000)", "NO_INDEX_MERGE(topics)")
+ # SELECT /*+ MAX_EXECUTION_TIME(50000) NO_INDEX_MERGE(topics) */ `topics`.* FROM `topics`
+
+ Example (for PostgreSQL with pg_hint_plan):
+
+ Topic.optimizer_hints("SeqScan(topics)", "Parallel(topics 8)")
+ # SELECT /*+ SeqScan(topics) Parallel(topics 8) */ "topics".* FROM "topics"
+
+ See also:
+
+ * https://dev.mysql.com/doc/refman/8.0/en/optimizer-hints.html
+ * https://pghintplan.osdn.jp/pg_hint_plan.html
+ * https://docs.oracle.com/en/database/oracle/oracle-database/12.2/tgsql/influencing-the-optimizer.html
+ * https://docs.microsoft.com/en-us/sql/t-sql/queries/hints-transact-sql-query?view=sql-server-2017
+ * https://www.ibm.com/support/knowledgecenter/en/SSEPGG_11.1.0/com.ibm.db2.luw.admin.perf.doc/doc/c0070117.html
+
+ *Ryuta Kamizono*
+
* Fix query attribute method on user-defined attribute to be aware of typecasted value.
For example, the following code no longer return false as casted non-empty string: