Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Send server-side query parameters in POST body instead of in URL #342

Open
aparshin opened this issue Apr 18, 2024 · 4 comments
Open

Send server-side query parameters in POST body instead of in URL #342

aparshin opened this issue Apr 18, 2024 · 4 comments
Labels
enhancement New feature or request

Comments

@aparshin
Copy link

Clickhouse connect supports server-side parameters of query requests, but always sends them as part of URI (particularly, as query parameters). If the server-side parameters are big enough, URL becomes too long and might be rejected by intermediate servers.

Clickhouse server starting from some version supports sending parameters for server-side binding as part of POST request's body: ClickHouse/ClickHouse#8842

It would be great to always send server-side parameters as part of body instead of query parameters in URL.

@aparshin aparshin added the enhancement New feature or request label Apr 18, 2024
@genzgd
Copy link
Collaborator

genzgd commented Apr 18, 2024

I had no idea this was possible (since it's not mentioned in the ClickHouse docs.). I think it's probably reasonable, but there are some tradeoffs -- sending everything as a Form to support this is kind of ugly, it adds complexity, and I'm pretty sure it's incompatible with the External Data approach. (Also, sending huge urls with very long parameter values probably means you're doing something really inefficient in your queries.)

@aparshin
Copy link
Author

@genzgd In our case, we just query rows with the exact match of a string column to a given string, but the problem is that we can't control size of that string. Sometimes it happens to be huge, which gives us an error from one of intermediate servers.

Generally speaking, putting something with uncontrolled length into URL is a bad practice. HTTP POST with its unlimited body size is a commonly used workaround to prevent such situations. From this point of view, moving all the parameters into body looks like a good improvement to me. Of course, I don't know how it fits to internal architecture. Also, not sure starting from what version this feature is supported at the server...

Meanwhile, the workaround we are going to implement is to use client-side parameters binding. In this case, all big strings will go to query POST body. But ideally we'd like to use sever-side binding.

@genzgd
Copy link
Collaborator

genzgd commented Apr 18, 2024

I agree with you philosophically about bloating the URL -- some time back we moved the query itself into the POST body for exactly that reason. I'm just not thrilled about using Form fields to do it with the current ClickHouse implementation, and it does add complexity, so this may not happen soon without an outside PR.

Side note -- having query parameters of uncontrolled size is also bad practice. :)

@aparshin
Copy link
Author

@genzgd Thank you for your feedback, anyway. Not sure that I'll be able to propose a PR for this....

Side note -- having query parameters of uncontrolled size is also bad practice. :)

I agree that it poses different problems, like the one we are discussing, but I just don't see any alternatives at client-side...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants