I'm looking for a way to give Postgres a value just for an index (as opposed to saving that value to a column and then indexing it). Similar to an index on an expression, but the expression will be computed outside of Postgres. If this is possible, how can it be done?
I've created an index on a plpgsql function that normalizes an email address, however using it is proving to be very clunky - either I have to remember to always call the function whenever I use the index, or I have to create a view and remember to use that for reads but not for writes... On top of that, the plpgsql implementation is 3x slower than the python implementation (and 30x uglier imo), and RDS doesn't support plpythonu. So I might as well go back to go back to doing it in the application, but I don't want to go back to saving a computed column and indexing on that; I still want to have the normalized email only in the index.
The way to do this I guess would be to somehow create a fake column name, and the input for this fake column would be used for the index. If this is possible, how can it be done?