Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1ihic3-0000fv-G5 for pgsql-general@arkaria.postgresql.org; Wed, 18 Dec 2019 23:20:15 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1ihic2-0001cg-52 for pgsql-general@arkaria.postgresql.org; Wed, 18 Dec 2019 23:20:14 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1ihic1-0001cZ-Nq for pgsql-general@lists.postgresql.org; Wed, 18 Dec 2019 23:20:13 +0000 Received: from tamriel.snowman.net ([96.255.250.162]) by makus.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1ihibs-00052D-A9 for pgsql-general@postgresql.org; Wed, 18 Dec 2019 23:20:09 +0000 Received: by tamriel.snowman.net (Postfix, from userid 1000) id 475765F799; Wed, 18 Dec 2019 18:20:03 -0500 (EST) Date: Wed, 18 Dec 2019 18:20:03 -0500 From: Stephen Frost To: Matthew Phillips Cc: pgsql-general@postgresql.org Subject: Re: READ UNCOMMITTED in postgres Message-ID: <20191218232003.GZ3195@tamriel.snowman.net> References: MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="EVmWh8UkjoBIyGkN" Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.24 (2015-08-30) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk --EVmWh8UkjoBIyGkN Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Greetings, * Matthew Phillips (mphillips34@gmail.com) wrote: > With the current READ UNCOMMITTED discussion happening on pgsql-hackers > [1], It did raise a question/use-case I recently encountered and could not > find a satisfactory solution for. If someone is attempting to poll for new > records on a high insert volume table that has a monotonically increasing > id, what is the best way to do it? As is, with a nave implementation, rows > are not guaranteed to appear in monotonic order; so if you were to keep a > $MAX_ID, and SELECT WHERE p_id > $MAX_ID, you would hit gaps. Is there a > clean way to do this? I've seen READ UNCOMMITTED used for this with DB2. There's the LISTEN/NOTIFY system, which at a high level is a better approach than using a polling system. Thanks, Stephen --EVmWh8UkjoBIyGkN Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQIcBAEBCgAGBQJd+rQiAAoJEO1sijiDR2RVmO4P+gP31abaGtImYqq2RKWkGwTL 9H5STEiqlHXNhy+rfzGnTKcissnNMbRKO0sJNU5ZhN8u3Y4wphUJZHBQHZKBk4lq DP9yYkbx7Hysfz3n8DhNcOj9Jl4501SqFRLn85l2ov+DC42dtXvoAZHd0VjcNCxl nXDf95EsYvwhpy4MYqzSvum8l5Qk5StMXYJdZNLEDcQu5XXTYcQ0b5BOJ98UQW2f x7aFHGBH05L6Ihh2SpjMnEtINmp3u3e3ZfD+TrQOqvTElR1KxBgxXTM7B99GUglZ Iixm8YJNL3GIbc7eyz4X/U9YTlMTo9UjnDfJQoPspOOri5li7RMlZSyHJwPb6Hyc +AwIr+0Vb727O+5Y5+naEnguYXY3IjQ1p0o8+3O+5BkZGe9T9qYlhnJ4YOnUut+p JTmKjAPhWMyyawns3eJ9XrBm3LJefXxo2VieYtMmivSs5mRCSiw9BpPScMwaOXIt J7Ouxkhlh99qDEW2S2ccdAzP0WFn2bgT8MpFnB8GgSfiLT+V7diZISIGRAzNb2zy V+F9wF+6jDAYOvIFGgTK2XPAow8y0qKRNaw19Fzb8crIA/z2MzaEyaqhpiNQE+DH 6H+jgFwf5J5pFLE4kD3DIJCl5eQYZjNOQWJQWgN0CE3S2y2Vj/Xfq0axVdHJxFKr kmlppXrngFoWmYZ9boda =cNqS -----END PGP SIGNATURE----- --EVmWh8UkjoBIyGkN--