Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix scope_identity rewrite for other types (yugabyte#102)
* Rewrite scope_identity on some index lookups Currently, a problem arises when using scope_identity to lookup on an index of identities. Babelfish implemented identity columns using INT sequences, but scope_identity returns a numeric type. Numeric has higher precedence than int, so the index column is implicitly cast to a numeric. However, this means queries that should use an index lookup instead use a sequential scan, significantly degrading performance. With this change, if a call to scope_identity or babelfish_get_last_identity_numeric (used with @@identity) is found in a where clause compared to an integer, the function is replaced with babelfish_get_last_identity, which returns an int so the index is used. Task: BABEL-3384 Signed-off-by: Walt Boettge <[email protected]> * Fix scope_identity rewrite for other types A previous commit rewrites scope_identity to return an integer so that an index may be used for certain queries. This only applied to columns of type integer, but identity columns can be of type smallint and bigint as well. Now, if scope_identity is compared against columns of these types the call will be rewritten and the index will be used. Signed-off-by: Walt Boettge <[email protected]>
- Loading branch information