Ver Mensaje Individual
  #14 (permalink)  
Antiguo 19/09/2007, 06:43
Avatar de Andres95
Andres95
Colaborador
 
Fecha de Ingreso: diciembre-2004
Mensajes: 1.802
Antigüedad: 19 años, 5 meses
Puntos: 38
Que no cunda el panico....

Cita:
Iniciado por iislas Ver Mensaje
Tal vez, para una tabla con unos 10, 000 registros, y teniendo un moustruo de servidor, con mucha memoria, muchos procesadores y una sola conexion, tal vez el ejemplo sea valido.


Todo eso para un select con un order by ?...




Cita:
Iniciado por iislas Ver Mensaje
Lo primero que cambiara, tal vez, sin conocer el PLAN DE EJECUCION de tu ejemplo, es NO DECLARAR TABLAS como variables, seria mucho mejor dejarlas como TABLAS TEMPORALES.
Libros en linea SQL Server...

Código:
Remarks
Functions and variables can be declared to be of type table. table variables can be used in functions, stored procedures, and batches.

Use table variables instead of temporary tables, whenever possible. table variables provide the following benefits: 

A table variable behaves like a local variable. It has a well-defined scope, which is the function, stored procedure, or batch in which it is declared. 
Within its scope, a table variable may be used like a regular table. It may be applied anywhere a table or table expression is used in SELECT, INSERT, UPDATE, and DELETE statements. However, table may not be used in the following statements:

INSERT INTO table_variable EXEC stored_procedure 

SELECT select_list INTO table_variable statements.

table variables are cleaned up automatically at the end of the function, stored procedure, or batch in which they are defined.

table variables used in stored procedures result in fewer recompilations of the stored procedures than when temporary tables are used.


Transactions involving table variables last only for the duration of an update on the table variable. Thus, table variables require less locking and logging resources.

Cita:
Iniciado por iislas Ver Mensaje
Pero bueno, esperemos que Lobo pruebe y nos diga que tal le fue.
Y bueno finalmente no le sirvio la propuesta...

Afortunadamente todos somos libres de tomar lo que se considere conveniente y aportar lo que se considere pueda servir a los demas...

Cita:
Iniciado por iislas Ver Mensaje
No siempre lo que proponemos, es lo mas adecuado, eso que ni que.
En eso si que tienes la razon...


Un saludo a ambos....
__________________
La sencillez y naturalidad son el supremo y último fin de la cultura...
--
MCTS : SQL Server 2008, .NET Framework 3.5, ASP.NET Applications.