I am currently working on a transaction engine, and we are having some issues with our locking mechanism and the wait time. So in order to fix the issue I am trying to simulate the process in a separate application. So I started the SQL profiler and processed a transaction. While looking at the queries, I noticed the following:
in the database my columns are defined as follows:
EVENTNBR (int),
DEPFILENBR (int),
DEPFILESEQ (int),
USERID (varchar(20)),
STATUS (varchar(1)),
CREATION_DT (datetime),
MOD_DT (datetime),
SOURCE_TYPE (varchar(100)),
SOURCE_GROUP (varchar(100)),
SOURCE_REFID (varchar(100)),
SOURCE_DATE (datetime),
CHECKSUM (varchar(50)),
however when I look at the query, say an insert statement in the SQL profiler, somehow, somewhere, the code is sending the following;
INSERT INTO TABLE_DATA WITH (ROWLOCK) (EVENTNBR, DEPFILENBR, DEPFILESEQ, USERID, STATUS, CREATION_DT, MOD_DT, SOURCE_TYPE, SOURCE_GROUP, SOURCE_REFID, SOURCE_DATE, CHECKSUM)
@mod_dt **varchar(19),**
@source_date **varchar(8000),**
@depfilenbr **varchar(7),**
@eventnbr **varchar(1),**
@source_refid **varchar(8000),**
@creation_dt **varchar(19)**,
@source_group varchar(8000),
@source_type **varchar(7),**
@userid **varchar(7)**,
@checksum **varchar(44)**,
@status **varchar(1)**,
@depfileseq **varchar(1)**',
Now the query is successful and works fine. I am wondering how expensive is this type conversion that is happening on the SQL side? If there is a million of these inserts happening, does correcting this makes a difference?
Thanks