DBLINK_SEND_QUERY(3)

okay bestie, so this is the page for dblink_send_query(3) from the PostgreSQL 18.6 docs, and honestly? it's giving fire-and-forget but make it SQL. πŸ’…


🌸 NAME 🌸

dblink_send_query β€” sends an async query to a remote database πŸ¦‹


πŸŽ€ SYNOPSIS πŸŽ€

dblink_send_query(text connname, text sql) returns int

πŸ’– DESCRIPTION πŸ’–

So here's the vibe: dblink_send_query fires off a query to be executed asynchronously, meaning it does not sit there waiting for the result like some clingy function. It just sends it and dips. ✈️

🚨 IMPORTANT GIRL MATH: there must not be an async query already in progress on that connection. One at a time, bestie. Don't be messy. πŸ™ˆ

Once you've successfully dispatched an async query, you can check on its completion status with dblink_is_busy, and then eventually collect the results with dblink_get_result. Also, if you're feeling spicy, you can attempt to cancel an active async query using dblink_cancel_query. πŸ”₯


✨ ARGUMENTS ✨

  • connname β€” the name of the connection you wanna use. your lil connection nickname, basically. πŸ’«
  • sql β€” the SQL statement you wish to execute in the remote database, for example select * from pg_class. yes, you literally type the SQL. iconic. πŸ‘‘

🌈 RETURN VALUE 🌈

Returns 1 if the query was successfully dispatched, 0 otherwise. slay or don't slay, there is no in between. 🫢


🧚 EXAMPLES 🧚

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

look at her go. query dispatched, no waiting, main character energy. ⭐


and that's the whole page, babe. this came out of the PostgreSQL 18.6 docs, dated 2026, so when you're out here async-querying remote databases, remember who told you how. mwah. πŸ’œ πŸ“ πŸŽ€