{"action":"created","issue":{"url":"https://api.github.com/repos/jackc/pgx/issues/94","labels_url":"https://api.github.com/repos/jackc/pgx/issues/94/labels{/name}","comments_url":"https://api.github.com/repos/jackc/pgx/issues/94/comments","events_url":"https://api.github.com/repos/jackc/pgx/issues/94/events","html_url":"https://github.com/jackc/pgx/issues/94","id":106514626,"number":94,"title":"has prepared statement","user":{"login":"emicklei","id":686220,"avatar_url":"https://avatars.githubusercontent.com/u/686220?v=3","gravatar_id":"","url":"https://api.github.com/users/emicklei","html_url":"https://github.com/emicklei","followers_url":"https://api.github.com/users/emicklei/followers","following_url":"https://api.github.com/users/emicklei/following{/other_user}","gists_url":"https://api.github.com/users/emicklei/gists{/gist_id}","starred_url":"https://api.github.com/users/emicklei/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/emicklei/subscriptions","organizations_url":"https://api.github.com/users/emicklei/orgs","repos_url":"https://api.github.com/users/emicklei/repos","events_url":"https://api.github.com/users/emicklei/events{/privacy}","received_events_url":"https://api.github.com/users/emicklei/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-09-15T09:08:48Z","updated_at":"2015-09-17T23:01:23Z","closed_at":null,"body":"In order to use the cached prepared statements of a connection, I need to conditionally create them.\r\n\r\n```\r\nif !conn.HasPreparedStatement(\"myname\") {\r\n    conn.Prepare(\"myname\", \"myquery\")\r\n}\r\n_, err = conn.Exec(\"myname\", args)\r\n```\r\n\r\nor should i use a different pattern here?  I noticed that it is calling Prepare too much because sendSimpleQuery associates each new prepared statement under \"\"  (why not use the sql as key?)"},"comment":{"url":"https://api.github.com/repos/jackc/pgx/issues/comments/141264441","html_url":"https://github.com/jackc/pgx/issues/94#issuecomment-141264441","issue_url":"https://api.github.com/repos/jackc/pgx/issues/94","id":141264441,"user":{"login":"jackc","id":94130,"avatar_url":"https://avatars.githubusercontent.com/u/94130?v=3","gravatar_id":"","url":"https://api.github.com/users/jackc","html_url":"https://github.com/jackc","followers_url":"https://api.github.com/users/jackc/followers","following_url":"https://api.github.com/users/jackc/following{/other_user}","gists_url":"https://api.github.com/users/jackc/gists{/gist_id}","starred_url":"https://api.github.com/users/jackc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jackc/subscriptions","organizations_url":"https://api.github.com/users/jackc/orgs","repos_url":"https://api.github.com/users/jackc/repos","events_url":"https://api.github.com/users/jackc/events{/privacy}","received_events_url":"https://api.github.com/users/jackc/received_events","type":"User","site_admin":false},"created_at":"2015-09-17T23:01:23Z","updated_at":"2015-09-17T23:01:23Z","body":"Can you create all your prepared statements ahead of time? That is what the AfterConnect hook is for.\r\n\r\nAs far as Prepare(\"\") -- it is special. The PostgreSQL wire protocol recognizes the unnamed prepared statement as a special temporary prepared statement."}}