Home All Groups Group Topic Archive Search About

Weird behavior with performance

Author
28 Apr 2006 9:26 AM
willem
don't know if this is a bug or an undocumented feature but i installed SQL
2005 on a server in our network. i wrote some php pages to connect and get
the data. I track the time what time i costs to execute to query through php.
And here comes to funny part:

if i open the sql management tool and i open any property window from a
database (table, index, view) i get much faster speeds. when i execute a
large query directly in sql server i get execution times of 1 seconderd and
lower (usually 0.21)

if i do this outside via PHP for example, the execution time is 2.4 ? But
when i open a property window in SQL manager and i do it again via PHP, the
execution time will be the same as if i executed it directly on the sql
server

how is this possible ??

Author
28 Apr 2006 1:14 PM
Erland Sommarskog
willem (wil***@discussions.microsoft.com) writes:
Show quote
>  don't know if this is a bug or an undocumented feature but i installed
>  SQL
> 2005 on a server in our network. i wrote some php pages to connect and
> get the data. I track the time what time i costs to execute to query
> through php. And here comes to funny part:
>
> if i open the sql management tool and i open any property window from a
> database (table, index, view) i get much faster speeds. when i execute a
> large query directly in sql server i get execution times of 1 seconderd
> and lower (usually 0.21)
>
> if i do this outside via PHP for example, the execution time is 2.4 ?
> But when i open a property window in SQL manager and i do it again via
> PHP, the execution time will be the same as if i executed it directly on
> the sql server
>
> how is this possible ??

It is not entirely clear to me exactly what you are doing, but keep in mind
that SQL Server maintains a cache. So the first time you read some data from
a table, the data is read from disk. But on subsequent accesses, the data is
already in memory, and access is much faster.



--
Erland Sommarskog, SQL Server MVP, esq***@sommarskog.se

Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/prodtechnol/sql/2005/downloads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodinfo/previousversions/books.mspx
Author
28 Apr 2006 5:54 PM
willem
I am aware of that, i solved the problem: if you take a look at database
properties
you will see an option "Auto close" with the default set to true. Set it to
false and it is solved but i still think this is strange behavior .

"Erland Sommarskog" schreef:

Show quote
> willem (wil***@discussions.microsoft.com) writes:
> >  don't know if this is a bug or an undocumented feature but i installed
> >  SQL
> > 2005 on a server in our network. i wrote some php pages to connect and
> > get the data. I track the time what time i costs to execute to query
> > through php. And here comes to funny part:
> >
> > if i open the sql management tool and i open any property window from a
> > database (table, index, view) i get much faster speeds. when i execute a
> > large query directly in sql server i get execution times of 1 seconderd
> > and lower (usually 0.21)
> >
> > if i do this outside via PHP for example, the execution time is 2.4 ?
> > But when i open a property window in SQL manager and i do it again via
> > PHP, the execution time will be the same as if i executed it directly on
> > the sql server
> >
> > how is this possible ??
>
> It is not entirely clear to me exactly what you are doing, but keep in mind
> that SQL Server maintains a cache. So the first time you read some data from
> a table, the data is read from disk. But on subsequent accesses, the data is
> already in memory, and access is much faster.
>
>
>
> --
> Erland Sommarskog, SQL Server MVP, esq***@sommarskog.se
>
> Books Online for SQL Server 2005 at
> http://www.microsoft.com/technet/prodtechnol/sql/2005/downloads/books.mspx
> Books Online for SQL Server 2000 at
> http://www.microsoft.com/sql/prodinfo/previousversions/books.mspx
>
Author
28 Apr 2006 10:11 PM
Erland Sommarskog
willem (wil***@discussions.microsoft.com) writes:
> I am aware of that, i solved the problem: if you take a look at database
> properties you will see an option "Auto close" with the default set to
> true. Set it to false and it is solved but i still think this is strange
> behavior .

With auto-close the database is closed when you disconnect. This gives
quite an overhead when you connect.

If you look at something in the database through Mgmt Studio, you keep
that connection open to the database, snd it never closes.


--
Erland Sommarskog, SQL Server MVP, esq***@sommarskog.se

Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/prodtechnol/sql/2005/downloads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodinfo/previousversions/books.mspx

AddThis Social Bookmark Button