Monday, March 19, 2012
Decrease Costs in INSERTS/UPDATES Queries.
I wanna know how can I do to reduce the Costs of INSERT/UPDATE Queries that I have, but in some Traces of SQL Profiler, I see that this queries taken most performance of my server.
Remember that all tables that I have are Indexed Tables with the default value of Fill Factor.
Tanks,The more indexes you have the longer an insert will take.
On heavy insert systems (telecoms for instance) I only ever have a single clustered index on the identity column of the call table.
For updates try not to update indexed fields, also do not extend the length of any fields then you should get a direct update in place (as long as you don't have triggers or replication enabled on the table) which is the fastest type (hope that statement is still valid).
Otherwise make sure the transaction log is on a different device to the data and that you are not getting contention on the table.
Friday, March 9, 2012
Decimals in SQL Server
SELECT 9 / CAST( 4 as float )
--results
2.25
bill|||Thanks. That did it.
Friday, February 24, 2012
Debugging Parameterized Queries
How would I debug such a query.
I have a sqlCommand to which I add several parameters for an insert statement.
if the statement fails, for some reason, I would like to copy the final sql with all values inserted as text and use this in e.g. TOAD to see where the error is coming from. Is this possible?
I have also been looking for this, but there does not seem to be a public property of the Command object that exposes this. I don't think it is actually stored in the object anywhere. I think it is created on the fly, when sent to the database.
What you can do however, if you don't have too many parameters, is to just copy/paste the SQL command into your TOAD. If you prefix your OracleParameters with : (instead of @.) then TOAD will ask you for the value of each parameter as you run your query.
Another option (although a bit cumbersome) is to write a function that actually parses the CommandText property and inserts the current values of the parameters, with respect to their datatype... But it would take some work to get it right ;-)