I have a huge partitioned table and I know partition name in advance before executing SELECT query.
In vanilla SQL the syntax is SELECT * FROM objects PARTITION (p1)
My current workaround seems to be working but looks kind of hacky:
active_record_relation.to_sql.gsub('FROM `objects`', "FROM `objects` PARTITION(#{explicit_partition_name})")
I'm wondering if there is a more idiomatic ActiveRecord solution to this?
Just to be clear, I'm aware of Partition Pruning but I can't use it, because partition hashing/finding logic is an external component/system.
The database is MySQL if that's important.