Comments on: ProxySQL Query Rewrite Use Case https://www.percona.com/blog/proxysql-query-rewrite-use-case/ Tue, 12 Mar 2019 15:48:24 +0000 hourly 1 https://wordpress.org/?v=6.5.2 By: Jeff https://www.percona.com/blog/proxysql-query-rewrite-use-case/#comment-10970458 Tue, 12 Mar 2019 15:48:24 +0000 https://www.percona.com/blog/?p=47922#comment-10970458 That sounds like a great idea, for (non-framework or) non-ORM applications. Sadly, to use it with most (frameworks or) ORMs (e.g.: Hibernate, Doctrine) would require modifying the ORM code, and probably the API (to pass in data on which to base the unique ID). In C, it could be done without modifying the API (using macros), but in a more “modern” language, it’s a much harder problem. (You _could_ look at the calling stack, but that’s painfully slow in the languages I’m familiar with.)

]]>
By: David https://www.percona.com/blog/proxysql-query-rewrite-use-case/#comment-10969159 Wed, 02 May 2018 23:28:06 +0000 https://www.percona.com/blog/?p=47922#comment-10969159 I’ve never had the proper time to play around with/implement proxysql since I first heard of it, but I always thought the following would be a good way to deal with query rewrites. Wonder what you think.

– Have application insert in-line comment with unique identifier into all queries sent from application, preferably at or near the front of the query. A decent example, and potentially automated would be an identifier of the filename and line #.
– When it is found that query needs rewriting, base your match pattern on the unique identifier.

This allows you to simply match on that unique identifier and then rewrite the rest of the query without hassle. You wouldn’t have to worry about similar queries that you do not want to rewrite, or that may match your non unique identifier. I haven’t tested it, but I do think it would work. I know there is a –comments option for the mysql command line tool that allows you to see such comments. I assume proxy sql can see the comments as well.

]]>