Implicit vs. Explicit Conversion
Posted: Mon Sep 09, 2013 9:46 pm
Hey guys,
Does anyone know if it's better in Vertica to explicitly convert all data types to the same when doing comparisons, or is okay to let Vertica do it implicitly? I know this was always a big deal in Oracle...
Say I have two tables A and B:
Which of the following query is a better practice?
Does anyone know if it's better in Vertica to explicitly convert all data types to the same when doing comparisons, or is okay to let Vertica do it implicitly? I know this was always a big deal in Oracle...
Say I have two tables A and B:
Code: Select all
dbadmin=> create table a (a1 int);
CREATE TABLE
dbadmin=> create table b (a1 varchar);
CREATE TABLE
dbadmin=> insert into a values (1);
OUTPUT
--------
1
(1 row)
dbadmin=> insert into b values ('1');
OUTPUT
--------
1
(1 row)
Code: Select all
dbadmin=> select * from a join b on a.a1 = b.a1;
a1 | a1
----+----
1 | 1
(1 row)
dbadmin=> select * from a join b on a.a1::varchar = b.a1;
a1 | a1
----+----
1 | 1
(1 row)
dbadmin=> select * from a join b on a.a1 = b.a1::int;
a1 | a1
----+----
1 | 1
(1 row)