jet icon indicating copy to clipboard operation
jet copied to clipboard

How to insert comment or fragment in sql?

Open canuran opened this issue 1 year ago • 3 comments

Such as select name from user /* shard_id=1 */ where name like 'can%', the shard_id comment is to tell the database proxy how to route to the sharded database.

Suggest: SELECT(User.Name).FROM(User).FRAG(FRAG("/* shard_id=1 */").BeforeWhere()).WHERE(...)

canuran avatar May 31 '23 07:05 canuran

Hi @canuran Can you use optimizer hints instead?

go-jet avatar Jun 03 '23 10:06 go-jet

Hi @canuran Can you use optimizer hints instead?

It seems impossible, optimizer_hints can only be used for mysql and the format is fixed, not suitable for prompting db proxy.

canuran avatar Jun 07 '23 09:06 canuran

What database proxy are you using? Does a comment have to appear at a specific position inside the statement?

houten11 avatar Jun 12 '23 17:06 houten11