DBLINK_SEND_QUERY(3)
π DBLINK_SEND_QUERY(3)
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 exampleselect * 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
- opensuse-leap 16.0: postgresql14-docs 14.24-160000.1.1 Β· PostgreSQL
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms