Tuesday, March 20, 2012

Optimization

I was asked to find out if there is any difference between the two queries
for performance.
Example 1:
Server: ServerProd
Database: DB1
Query: Select * from Table1
Example 2:
Server: ServerProd
Database: DB2
Query: Select * from DB1..Table1
Does anybody know?
AngieThere is no difference. See with the query plan.
"Angela Shinkle" <ashinkle@.aspenmed.org> wrote in message
news:OhdCXAXpDHA.2772@.TK2MSFTNGP10.phx.gbl...
> I was asked to find out if there is any difference between the two queries
> for performance.
> Example 1:
> Server: ServerProd
> Database: DB1
> Query: Select * from Table1
>
> Example 2:
> Server: ServerProd
> Database: DB2
> Query: Select * from DB1..Table1
>
> Does anybody know?
> Angie
>|||no comment on this, but if the user and owner are
different, it will help to specify the table owner
>--Original Message--
>I was asked to find out if there is any difference
between the two queries
>for performance.
>Example 1:
> Server: ServerProd
> Database: DB1
> Query: Select * from Table1
>
>Example 2:
> Server: ServerProd
> Database: DB2
> Query: Select * from
DB1..Table1
>
>Does anybody know?
>Angie
>
>.
>|||If anything I would think the DB1..Table1 would be slower, however,
specifying the ownername for your table stops SQL from having to search on
your username to see if you have a table name that, so select * from
dbo.table1 is slightly faster than select * from table1 as SQL would go out
and see if there were any tables named yourusername.table1 and if not, then
select dbo.table1
HTH
--
Ray Higdon MCSE, MCDBA, CCNA
--
"Angela Shinkle" <ashinkle@.aspenmed.org> wrote in message
news:OhdCXAXpDHA.2772@.TK2MSFTNGP10.phx.gbl...
> I was asked to find out if there is any difference between the two queries
> for performance.
> Example 1:
> Server: ServerProd
> Database: DB1
> Query: Select * from Table1
>
> Example 2:
> Server: ServerProd
> Database: DB2
> Query: Select * from DB1..Table1
>
> Does anybody know?
> Angie
>|||Yep, I did some tests a while ago.
dbo.tblname is the fastest.
Including database name is slightly slower, even if you already are in the
correct database.
--
Tibor Karaszi, SQL Server MVP
Archive at:
http://groups.google.com/groups?oi=djq&as_ugroup=microsoft.public.sqlserver
"Ray Higdon" <rayhigdon@.higdonconsulting.com> wrote in message
news:OTjHfnYpDHA.2500@.TK2MSFTNGP10.phx.gbl...
> If anything I would think the DB1..Table1 would be slower, however,
> specifying the ownername for your table stops SQL from having to search on
> your username to see if you have a table name that, so select * from
> dbo.table1 is slightly faster than select * from table1 as SQL would go
out
> and see if there were any tables named yourusername.table1 and if not,
then
> select dbo.table1
> HTH
> --
> Ray Higdon MCSE, MCDBA, CCNA
> --
> "Angela Shinkle" <ashinkle@.aspenmed.org> wrote in message
> news:OhdCXAXpDHA.2772@.TK2MSFTNGP10.phx.gbl...
> > I was asked to find out if there is any difference between the two
queries
> > for performance.
> >
> > Example 1:
> > Server: ServerProd
> > Database: DB1
> > Query: Select * from Table1
> >
> >
> > Example 2:
> > Server: ServerProd
> > Database: DB2
> > Query: Select * from DB1..Table1
> >
> >
> > Does anybody know?
> >
> > Angie
> >
> >
>

No comments:

Post a Comment