page92
74
sql_stmt += "AND total_elapsed_time > 1000;"
//Execution time must be over 1s, queries which used compute
stmt = snowflake.createStatement( { sqlText: sql_stmt } );
try
{
recset = stmt.execute();
while(recset.next())
{
query_id = recset.getColumnValue(1);
sql_stmt = "INSERT INTO cartesian_join_queries\n"
sql_stmt += "SELECT 'sp_get_cartesian_join_queries',\n"
sql_stmt += " query_id,\n"
sql_stmt += " operator_type,\n"
sql_stmt += " operator_id,\n"
sql_stmt += " operator_attributes,\n"
sql_stmt += " operator_statistics:output_rows /\n"
sql_stmt += " operator_statistics:input_rows AS row_
multiple\n"
sql_stmt += "FROM TABLE ( get_query_operator_stats('" + query_id
+ "'))\n"
sql_stmt += "WHERE operator_type = 'CartesianJoin';"
stmt = snowflake.createStatement ({ sqlText:sql_stmt });
try
{
stmt.execute();
result = "Success";
}
catch { result = sql_stmt; }
}
result = "Success";
}
catch(err)
{
err_state += "\nFail Code: " + err.code;
err_state += "\nState: " + err.state;
ChapTer 3
The Query profiler