On Thu, 3 Dec 2026 at 10:07, Corey Huinker <[email protected]> wrote:
> 2. customers with at least 1 money column: 2.68%

> I had hoped that this research would show that usage was vanishingly small, 
> giving us a reason to pursue a more aggressive deprecation schedule, but that 
> doesn't appear to be the case.

Yeah. I'm surprised. Could you get some stats on indexes using money_ops?: e.g:

SELECT count(*) FROM pg_index WHERE (SELECT oid FROM pg_opclass WHERE
opcname = 'money_ops') = ANY (indclass::oid[]);

In theory, if we were to ever move money to contrib, then providing
another type based on int64 / 100 and adding a WITHOUT FUNCTION cast
would allow switching to the new type without table rewrites.

I once wrote a type called fixeddecimal [1] which does that, same as
money. The following seems to work without a table rewrite.

CREATE EXTENSION IF NOT EXISTS fixeddecimal;
CREATE CAST (money AS fixeddecimal) WITHOUT FUNCTION AS ASSIGNMENT;
CREATE TABLE m (a money);
INSERT INTO m SELECT 123.45 FROM generate_series(1,1000000);
\timing on
ALTER TABLE m ALTER COLUMN a TYPE fixeddecimal;
\timing off
SELECT * FROM m LIMIT 10;

But it's slow if you create an index on m(a) as the index needs rebuilt.

David

[1] https://github.com/2ndQuadrant/fixeddecimal (I did need to adjust
the Makefile to change "12" to "20")


Reply via email to