diff options
author | Ryuta Kamizono <kamipo@gmail.com> | 2019-04-04 11:16:45 +0900 |
---|---|---|
committer | Ryuta Kamizono <kamipo@gmail.com> | 2019-04-04 11:51:36 +0900 |
commit | 7fb2ba5ed85abe210f33eb49e5820cfe8973530d (patch) | |
tree | 20cbfe3e405d6d1aba2c0a01b899e6a622d62665 /activerecord/test/cases/adapters/postgresql | |
parent | 464d625324accb8486aefa0b4a4b46477462dd08 (diff) | |
download | rails-7fb2ba5ed85abe210f33eb49e5820cfe8973530d.tar.gz rails-7fb2ba5ed85abe210f33eb49e5820cfe8973530d.tar.bz2 rails-7fb2ba5ed85abe210f33eb49e5820cfe8973530d.zip |
Optimizer hints should be applied on Top level query as much as possible
I've experienced this issue in our app, some hints only works on Top
level query (e.g. `MAX_EXECUTION_TIME`).
Diffstat (limited to 'activerecord/test/cases/adapters/postgresql')
-rw-r--r-- | activerecord/test/cases/adapters/postgresql/optimizer_hints_test.rb | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/activerecord/test/cases/adapters/postgresql/optimizer_hints_test.rb b/activerecord/test/cases/adapters/postgresql/optimizer_hints_test.rb index 5e4bf232e1..5b9f5e0832 100644 --- a/activerecord/test/cases/adapters/postgresql/optimizer_hints_test.rb +++ b/activerecord/test/cases/adapters/postgresql/optimizer_hints_test.rb @@ -19,6 +19,14 @@ if supports_optimizer_hints? end end + def test_optimizer_hints_with_count_subquery + assert_sql(%r{\ASELECT /\*\+ SeqScan\(posts\) \*/}) do + posts = Post.optimizer_hints("SeqScan(posts)") + posts = posts.select(:id).where(author_id: [0, 1]).limit(5) + assert_equal 5, posts.count + end + end + def test_optimizer_hints_is_sanitized assert_sql(%r{\ASELECT /\*\+ SeqScan\(posts\) \*/}) do posts = Post.optimizer_hints("/*+ SeqScan(posts) */") |