DBLINK_SEND_QUERY(3)

πŸ“¦ version 14.24, in opensuse-leap 16.0

okay so real talk, bestie β€” this one lives in the PostgreSQL 14.24 Documentation and it's genuinely one of the slay-est little functions in the dblink family. Let me put you on. 🫢


✨ NAME ✨

dblink_send_query β€” sends an async query to a remote database. literally fires it off and dips, no waiting around πŸ’¨


πŸŽ€ SYNOPSIS πŸŽ€

dblink_send_query(text connname, text sql) returns int

like that's the whole signature. connname and sql, both text, and you get an int back. iconic. πŸ‘‘


🌸 DESCRIPTION 🌸

dblink_send_query sends a query to be executed asynchronously β€” meaning it dispatches the query without immediately waiting for the result. it's giving "sent the text, not refreshing the chat" energy, fr fr. πŸ“±

⚠️ but bestie, hear me β€” there must not be an async query already in progress on the connection. one at a time, okay? don't be messy. πŸ’€

after you've successfully dispatched an async query, you can check the completion status with dblink_is_busy, and the results are ultimately collected with dblink_get_result. you can also attempt to cancel an active async query using dblink_cancel_query. so the whole little friend group is:

  • dblink_is_busy β†’ vibe check on whether it's still cooking πŸ”₯
  • dblink_get_result β†’ actually collects the results at the end 🌈
  • dblink_cancel_query β†’ the "nvm bestie" button πŸ™ˆ

πŸ¦‹ ARGUMENTS πŸ¦‹

  • connname β€” the name of the connection to use. your group chat of choice, basically. πŸ’Œ
  • sql β€” the SQL statement that you wish to execute in the remote database, for example select * from pg_class. go off, query queen. ⭐

πŸ‘‘ RETURN VALUE πŸ‘‘

returns 1 if the query was successfully dispatched, and 0 otherwise. that's it, that's the whole verdict β€” no nuance, no essay, just a lil number. πŸ“


🧚 EXAMPLES 🧚

okay here's the moment, here's the demo β€” no cap:

SELECT dblink_send_query('dtest1', 'SELECT * FROM foo WHERE f1 < 3');

and yes the connection is 'dtest1' and yes the query is exactly that. copy-paste ready. πŸ’…


✨ and that's the page, bestie ✨ β€” shoutout to the PostgreSQL 14.24 docs, dated 2026, for giving us this absolute banger. see you in the next manpage, mwah πŸŽ€πŸ’–

πŸ“¦ where this page comes from