on ‎2013 Jan 09 7:16 AM
After starting the database when the first query takes longer to run. For example, a simple query to get the date of the last sale, after this consultation the other run faster:
select max(date_sale) as data_sale from tbsales, tbsales_tribute where tbsales.emp = tbsales_tribute.emp and tbsales.sale = tbsales_tribute.sale and tbsales.emp = 1 and tbsales_tribute.type = 5
or
select max(date_sale) as data_sale from tbsales key join tbsales_tribute where tbsales.emp = 1 and tbsales_tribute.type = 5
or
select max (date_sale) as data_sale from tbsales join tbsales_tribute on (tbsales_tribute.emp = tbsales.emp and tbsales_tribute.sale = tbsales.sale) where tbsales.emp = 1 and tbsales_tribute.type = 5
Which of these queries is more optimized?
(a friend told me that we should always use the sybase key join instead of join, key join the reserved word always makes the query more optimized, so pe truth? where I can find material about?)
Request clarification before answering.
The three queries are equivalent for the optimizer and the execution part. You may need additional indexes and/or cache warming. Check the first query execuion using the Index Consultant and the Plan Viewer.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
| User | Count |
|---|---|
| 5 | |
| 5 | |
| 4 | |
| 3 | |
| 3 | |
| 2 | |
| 2 | |
| 2 | |
| 1 | |
| 1 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.