Гость
Целевая тема:
Создать новую тему:
Автор:
Форумы / Sybase ASA, ASE, IQ [игнор отключен] [закрыт для гостей] / ASE 12.5.1 висит перекресный запрос / 3 сообщений из 3, страница 1 из 1
29.01.2009, 17:51
    #35786353
Badger
Участник
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
ASE 12.5.1 висит перекресный запрос
Добрый день.
Столкнулся с необъяснимой, нестандартной ситуацией.
Не могу понять, почему долго делается перекрестный запрос при выборки первичного ключа, по двум табличкам. Во всех остальных случаях этот же запрос работает моментально! Индексы не помогают, результат стабилен на разных дампах и даже на разном железе. Что нужно сделать с таблицей, чтобы она ожила? Update All Statistics предлагать не стоит.


Подробности
Код: plaintext
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
25.
26.
27.
28.
29.
30.
31.
32.
33.
34.
35.
36.
37.
38.
39.
40.
41.
42.
43.
44.
45.
46.
47.
48.
49.
50.
51.
52.
53.
54.
55.
56.
57.
58.
59.
60.
61.
62.
63.
64.
65.
66.
67.
68.
69.
70.
71.
72.
73.
74.
75.
76.
77.
78.
79.
80.
81.
82.
83.
84.
85.
86.
87.
88.
89.
90.
91.
92.
93.
94.
95.
96.
97.
98.
99.
100.
101.
102.
103.
104.
105.
106.
107.
108.
109.
110.
111.
112.
113.
114.
115.
116.
117.
118.
119.
120.
121.
122.
123.
124.
125.
126.
127.
128.
129.
130.
131.
132.
133.
134.
135.
136.
137.
138.
139.
140.
141.
142.
143.
144.
145.
146.
147.
148.
149.
150.
151.
152.
153.
154.
155.
156.
157.
158.
159.
160.
161.
162.
163.
164.
165.
166.
167.
168.
169.
170.
171.
172.
173.
174.
175.
176.
177.
178.
179.
180.
181.
182.
183.
184.
185.
186.
187.
188.
189.
190.
191.
192.
193.
194.
195.
196.
197.
198.
199.
200.
201.
202.
203.
204.
205.
206.
207.
208.
209.
210.
211.
212.
213.
214.
215.
216.
217.
218.
219.
220.
221.
222.
223.
224.
225.
226.
227.
228.
229.
230.
231.
232.
233.
234.
235.
236.
237.
238.
239.
240.
241.
242.
243.
244.
245.
246.
247.
248.
249.
250.
251.
252.
253.
254.
255.
256.
257.
258.
259.
260.
261.
262.
263.
264.
265.
266.
267.
268.
269.
270.
271.
272.
273.
274.
275.
276.
277.
278.
279.
280.
281.
282.
283.
284.
285.
286.
287.
288.
289.
290.
291.
292.
293.
294.
295.
296.
297.
298.
299.
300.
301.
302.
303.
304.
305.
306.
307.
308.
309.
310.
311.
312.
313.
314.
315.
316.
317.
318.
319.
320.
321.
322.
323.
324.
325.
326.
327.
328.
329.
330.
331.
332.
333.
334.
335.
336.
337.
338.
339.
340.
341.
342.
343.
344.
345.
346.
347.
348.
349.
350.
351.
352.
353.
354.
355.
356.
357.
358.
359.
360.
361.
362.
363.
364.
365.
366.
367.
368.
369.
370.
371.
372.
373.
374.
375.
376.
377.
378.
379.
380.
381.
382.
383.
384.
385.
386.
387.
388.
389.
390.
391.
392.
393.
394.
395.
396.
397.
398.
399.
400.
401.
402.
403.
404.
405.
406.
407.
408.
409.
410.
411.
412.
413.
414.
415.
416.
417.
418.
419.
420.
421.
422.
423.
424.
425.
426.
427.
428.
429.
430.
431.
432.
433.
434.
435.
436.
437.
438.
439.
440.
441.
442.
443.
444.
445.
446.
447.
448.
449.
450.
451.
452.
453.
454.
455.
456.
457.
458.
459.
460.
461.
462.
463.
464.
465.
466.
467.
468.
469.
470.
471.
472.
473.
474.
475.
476.
477.
478.
479.
480.
481.
482.
483.
484.
485.
486.
487.
488.
489.
490.
491.
492.
493.
494.
495.
496.
497.
498.
499.
500.
501.
502.
503.
504.
505.
506.
507.
508.
509.
510.
511.
512.
513.
514.
515.
516.
517.
518.
519.
520.
521.
522.
523.
524.
525.
526.
527.
528.
529.
530.
531.
532.
533.
534.
535.
536.
537.
538.
539.
540.
541.
542.
543.
544.
545.
546.
547.
548.
549.
550.
551.
552.
553.
554.
555.
556.
557.
558.
559.
560.
561.
562.
563.
564.
565.
566.
567.
568.
569.
570.
571.
572.
573.
574.
575.
576.
577.
578.
579.
580.
581.
582.
583.
584.
585.
586.
587.
588.
589.
590.
591.
592.
593.
594.
595.
596.
597.
598.
599.
600.
601.
602.
603.
604.
605.
606.
607.
608.
609.
610.
611.
612.
613.
614.
615.
616.
617.
618.
619.
620.
621.
622.
623.
624.
625.
626.
627.
628.
629.
630.
631.
632.
633.
634.
635.
636.
637.
638.
639.
640.
641.
642.
643.
644.
645.
646.
647.
648.
649.
650.
651.
652.
653.
654.
655.
656.
657.
658.
659.
660.
661.
662.
663.
664.
665.
666.
667.
668.
669.
670.
671.
672.
673.
674.
675.
676.
677.
678.
679.
680.
681.
682.
683.
684.
685.
686.
687.
688.
689.
690.
691.
692.
693.
694.
695.
696.
697.
698.
699.
700.
701.
702.
703.
704.
705.
706.
707.
708.
709.
710.
711.
712.
713.
714.
715.
716.
717.
718.
719.
720.
721.
722.
723.
724.
725.
726.
727.
728.
729.
730.
731.
732.
733.
734.
735.
736.
737.
738.
739.
740.
741.
742.
743.
744.
745.
746.
747.
748.
749.
750.
751.
752.
753.
754.
755.
756.
757.
758.
759.
760.
761.
762.
763.
764.
765.
766.
767.
768.
769.
770.
771.
772.
773.
774.
775.
776.
777.
778.
779.
780.
781.
782.
783.
784.
785.
786.
787.
788.
789.
790.
791.
792.
793.
794.
795.
796.
797.
798.
799.
800.
801.
802.
803.
804.
805.
806.
807.
808.
809.
810.
811.
812.
813.
814.
815.
DECLARE     @f_user  int
   set         @f_user =  6  

   DELETE FROM w_getdate
   INSERT INTO w_getdate   SELECT  1 , GetDate (), DATEDIFF(ms,Max (date_time),GetDate ()) FROM w_getdate
   /* всегда работает моментально! */
   SELECT
           f_sum.f_sum
   FROM
           l_dealuser,
           f_sum
   WHERE
           l_dealuser.f_deal = f_sum.f_deal AND
           l_dealuser.f_user =  6 

   INSERT INTO w_getdate   SELECT  2 , GetDate (), DATEDIFF(ms,Max (date_time),GetDate ()) FROM w_getdate
   
   /* Висит всегда две с плоловиной секунды ! */   
   /*  Нужно чтобы эта выборка работала!!!! */
   SELECT
           f_sum.f_sum
   FROM
           l_dealuser,
           f_sum
   WHERE
           l_dealuser.f_deal = f_sum.f_deal AND
           l_dealuser.f_user = @f_user
           
   /******************************************************************************/
           
   INSERT INTO w_getdate   SELECT  3 , GetDate (), DATEDIFF(ms,Max (date_time),GetDate ()) FROM w_getdate
   
   /* всегда работает моментально! */
   SELECT
           f_sum.f_deal
   FROM
           l_dealuser,
           f_sum
   WHERE
           l_dealuser.f_deal = f_sum.f_deal AND
           l_dealuser.f_user =  6 
           
   INSERT INTO w_getdate   SELECT  3 , GetDate (), DATEDIFF(ms,Max (date_time),GetDate ()) FROM w_getdate
   
   /* всегда работает моментально! */
   SELECT
           f_sum.f_deal
   FROM
           l_dealuser,
           f_sum
   WHERE
           l_dealuser.f_deal = f_sum.f_deal AND
           l_dealuser.f_user = @f_user

   INSERT INTO w_getdate   SELECT  4 , GetDate (), DATEDIFF(ms,Max (date_time),GetDate ()) FROM w_getdate

   /* повтор второго  */
   /* Висит всегда две с плоловиной секунды ! */   
   /*  Нужно чтобы эта выборка работала!!!! */
   SELECT
           f_sum.f_sum
   FROM
           l_dealuser,
           f_sum
   WHERE
           l_dealuser.f_deal = f_sum.f_deal AND
           l_dealuser.f_user = @f_user

   INSERT INTO w_getdate   SELECT  5 , GetDate (), DATEDIFF(ms,Max (date_time),GetDate ()) FROM w_getdate

   SELECT * FROM w_getdate   
   
/*   
   /* Результат выборки!!! */
A	B	C
f_sum		
 118076828 		
 118076829 		
 118076830 		
 118076835 		
 118076836 		
 118076837 		
 118076838 		
 118076839 		
 118076840 		
 118076841 		
 118076842 		
 118076843 		
 118077536 		
 118077537 		
 118077538 		
 118077539 		
 118077540 		
 118077541 		
 118077548 		
 118077550 		
 118077549 		
 118077552 		
 118077551 		
 118077553 		
		
f_sum		
 118076828 		
 118076829 		
 118076830 		
 118076835 		
 118076836 		
 118076837 		
 118076838 		
 118076839 		
 118076840 		
 118076841 		
 118076842 		
 118076843 		
 118077548 		
 118077550 		
 118077552 		
 118077549 		
 118077551 		
 118077553 		
 118077536 		
 118077537 		
 118077538 		
 118077539 		
 118077540 		
 118077541 		
		
f_deal		
 40667661 		
 40667661 		
 40667661 		
 40667663 		
 40667663 		
 40667663 		
 40667664 		
 40667664 		
 40667664 		
 40667665 		
 40667665 		
 40667665 		
 40667699 		
 40667699 		
 40667699 		
 40667700 		
 40667700 		
 40667700 		
 40667703 		
 40667703 		
 40667703 		
 40667704 		
 40667704 		
 40667704 		
		
f_deal		
 40667661 		
 40667661 		
 40667661 		
 40667663 		
 40667663 		
 40667663 		
 40667664 		
 40667664 		
 40667664 		
 40667665 		
 40667665 		
 40667665 		
 40667699 		
 40667699 		
 40667699 		
 40667700 		
 40667700 		
 40667700 		
 40667703 		
 40667703 		
 40667703 		
 40667704 		
 40667704 		
 40667704 		
		
f_sum		
 118076828 		
 118076829 		
 118076830 		
 118076835 		
 118076836 		
 118076837 		
 118076838 		
 118076839 		
 118076840 		
 118076841 		
 118076842 		
 118076843 		
 118077548 		
 118077550 		
 118077552 		
 118077549 		
 118077551 		
 118077553 		
 118077536 		
 118077537 		
 118077538 		
 118077539 		
 118077540 		
 118077541 		
		
num	date_time	sec
 1 	 29 . 01 . 2009   17 : 27 : 19 . 873 	[NULL]
 2 	 29 . 01 . 2009   17 : 27 : 19 . 873 	 0 
 3 	 29 . 01 . 2009   17 : 27 : 22 . 733 	 2860 
 3 	 29 . 01 . 2009   17 : 27 : 22 . 733 	 0 
 4 	 29 . 01 . 2009   17 : 27 : 22 . 733 	 0 
 5 	 29 . 01 . 2009   17 : 27 : 25 . 450 	 2716 

 **/ 
  
/* Таблици */ 
/*
CREATE TABLE dbo.f_sum 
(
    f_sum       int           NOT NULL,
    f_deal      int           NULL,
    f_sumtype   int           NULL,
    c_sumkind   int           NULL,
    c_currency  int           NULL,
    f_account   int           NULL,
    stat        int           NULL,
    date_time   datetime      NULL,
    date_pay    datetime      NULL,
    value       decimal(18,6) NULL,
    value_pay   decimal(18,6) NULL,
    name        varchar(30)   NULL,
    unlimited   int           NULL,
    dt_modify   datetime      NULL,
    user_modify varchar(30)   NULL,
    rate        decimal(18,6) NULL,
    procent     decimal(18,6) NULL,
    f_user      int           NULL,
    CONSTRAINT pk_f_sum
    PRIMARY KEY CLUSTERED (f_sum),
CONSTRAINT fk_f_sum_sum_curre_c_curren
    FOREIGN KEY (c_currency)
    REFERENCES dbo.c_currency (c_currency),
CONSTRAINT fk_f_sum_sum_kind_c_sumkin
    FOREIGN KEY (c_sumkind)
    REFERENCES dbo.c_sumkind (c_sumkind),
CONSTRAINT fk_f_sum_sum_deal_f_deal
    FOREIGN KEY (f_deal)
    REFERENCES dbo.f_deal (f_deal),
CONSTRAINT fk_f_sum_sum_acc_f_accoun
    FOREIGN KEY (f_account)
    REFERENCES dbo.f_account (f_account),
CONSTRAINT fk_f_sum_sum_user_f_user
    FOREIGN KEY (f_user)
    REFERENCES dbo.f_user (f_user),
CONSTRAINT fk_f_sum_sum_type_f_sumtyp
    FOREIGN KEY (f_sumtype)
    REFERENCES dbo.f_sumtype (f_sumtype)
)
LOCK DATAPAGES


CREATE TABLE dbo.l_dealuser 
(
    l_dealuser int NOT NULL,
    f_deal     int NULL,
    f_user     int NULL,
    CONSTRAINT pk_l_dealuser
    PRIMARY KEY CLUSTERED (l_dealuser),
CONSTRAINT fk_l_dealus_deus_deal_f_deal
    FOREIGN KEY (f_deal)
    REFERENCES dbo.f_deal (f_deal),
CONSTRAINT fk_l_dealus_deus_user_f_user
    FOREIGN KEY (f_user)
    REFERENCES dbo.f_user (f_user)
)
LOCK DATAPAGES

CREATE TABLE dbo.w_getdate 
(
    num       int      NULL,
    date_time datetime NULL,
    sec       int      NULL
)

Select @@version 
Adaptive Server Enterprise/12.5.1/EBF 11665 ESD#2/P/NT (IX86)/OS 4.0/ase1251/1838/32-bit/OPT/Fri Feb 20 04:11:31 2004

SELECT Count (*) FROM l_dealuser 
498

SELECT Count (*) FROM f_sum
732473

*/
  
/* Получение плана и статистику по SQL запросу для следующих команд */
/*
set showplan on
set statistics io on
set statistics time on
go
  
A

Total writes for this command: 0 
Total writes for this command: 0 
Execution Time 0. 
SQL Server cpu time: 0 ms.  SQL Server elapsed time: 0 ms.
Execution Time 0. 
SQL Server cpu time: 0 ms.  SQL Server elapsed time: 190 ms.
QUERY PLAN FOR STATEMENT 1 (at line 2). 
STEP 1 
The type of query is DECLARE. 
QUERY PLAN FOR STATEMENT 2 (at line 3). 
STEP 1 
The type of query is SELECT. 
QUERY PLAN FOR STATEMENT 3 (at line 5). 
STEP 1 
The type of query is DELETE. 
The update mode is direct. 
FROM TABLE 
w_getdate 
Nested iteration. 
Table Scan. 
Forward scan. 
Positioning at start of table. 
Using I/O Size 2 Kbytes for data pages. 
With LRU Buffer Replacement Strategy for data pages. 
TO TABLE 
w_getdate 
Using I/O Size 2 Kbytes for data pages. 
QUERY PLAN FOR STATEMENT 4 (at line 6). 
STEP 1 
The type of query is SELECT. 
Evaluate Ungrouped MAXIMUM AGGREGATE. 
FROM TABLE 
w_getdate 
Nested iteration. 
Table Scan. 
Forward scan. 
Positioning at start of table. 
Using I/O Size 2 Kbytes for data pages. 
With LRU Buffer Replacement Strategy for data pages. 
STEP 2 
The type of query is INSERT. 
The update mode is deferred. 
TO TABLE 
w_getdate 
Using I/O Size 2 Kbytes for data pages. 
QUERY PLAN FOR STATEMENT 5 (at line 8). 
STEP 1 
The type of query is SELECT. 
FROM TABLE 
l_dealuser 
Nested iteration. 
Index : deus_user 
Forward scan. 
Positioning by key. 
Keys are: 
f_user  ASC 
Using I/O Size 2 Kbytes for index leaf pages. 
With LRU Buffer Replacement Strategy for index leaf pages. 
Using I/O Size 2 Kbytes for data pages. 
With LRU Buffer Replacement Strategy for data pages. 
FROM TABLE 
f_sum 
Nested iteration. 
Index : sum_deal 
Forward scan. 
Positioning by key. 
Keys are: 
f_deal  ASC 
Using I/O Size 2 Kbytes for index leaf pages. 
With LRU Buffer Replacement Strategy for index leaf pages. 
Using I/O Size 2 Kbytes for data pages. 
With LRU Buffer Replacement Strategy for data pages. 
QUERY PLAN FOR STATEMENT 6 (at line 17). 
STEP 1 
The type of query is SELECT. 
Evaluate Ungrouped MAXIMUM AGGREGATE. 
FROM TABLE 
w_getdate 
Nested iteration. 
Table Scan. 
Forward scan. 
Positioning at start of table. 
Using I/O Size 2 Kbytes for data pages. 
With LRU Buffer Replacement Strategy for data pages. 
STEP 2 
The type of query is INSERT. 
The update mode is deferred. 
TO TABLE 
w_getdate 
Using I/O Size 2 Kbytes for data pages. 
QUERY PLAN FOR STATEMENT 7 (at line 21). 
STEP 1 
The type of query is INSERT. 
The update mode is direct. 
Worktable1 created for REFORMATTING. 
FROM TABLE 
l_dealuser 
Nested iteration. 
Index : deus_user 
Forward scan. 
Positioning by key. 
Keys are: 
f_user  ASC 
Using I/O Size 2 Kbytes for index leaf pages. 
With LRU Buffer Replacement Strategy for index leaf pages. 
Using I/O Size 2 Kbytes for data pages. 
With LRU Buffer Replacement Strategy for data pages. 
TO TABLE 
Worktable1. 
STEP 2 
The type of query is SELECT. 
FROM TABLE 
f_sum 
Nested iteration. 
Table Scan. 
Forward scan. 
Positioning at start of table. 
Using I/O Size 2 Kbytes for data pages. 
With LRU Buffer Replacement Strategy for data pages. 
FROM TABLE 
Worktable1. 
Nested iteration. 
Using Clustered Index. 
Forward scan. 
Positioning by key. 
Using I/O Size 2 Kbytes for data pages. 
With LRU Buffer Replacement Strategy for data pages. 
QUERY PLAN FOR STATEMENT 8 (at line 32). 
STEP 1 
The type of query is SELECT. 
Evaluate Ungrouped MAXIMUM AGGREGATE. 
FROM TABLE 
w_getdate 
Nested iteration. 
Table Scan. 
Forward scan. 
Positioning at start of table. 
Using I/O Size 2 Kbytes for data pages. 
With LRU Buffer Replacement Strategy for data pages. 
STEP 2 
The type of query is INSERT. 
The update mode is deferred. 
TO TABLE 
w_getdate 
Using I/O Size 2 Kbytes for data pages. 
QUERY PLAN FOR STATEMENT 9 (at line 35). 
STEP 1 
The type of query is SELECT. 
FROM TABLE 
l_dealuser 
Nested iteration. 
Index : deus_user 
Forward scan. 
Positioning by key. 
Keys are: 
f_user  ASC 
Using I/O Size 2 Kbytes for index leaf pages. 
With LRU Buffer Replacement Strategy for index leaf pages. 
Using I/O Size 2 Kbytes for data pages. 
With LRU Buffer Replacement Strategy for data pages. 
FROM TABLE 
f_sum 
Nested iteration. 
Index : sum_deal 
Forward scan. 
Positioning by key. 
Index contains all needed columns. Base table will not be read. 
Keys are: 
f_deal  ASC 
Using I/O Size 2 Kbytes for index leaf pages. 
With LRU Buffer Replacement Strategy for index leaf pages. 
QUERY PLAN FOR STATEMENT 10 (at line 44). 
STEP 1 
The type of query is SELECT. 
Evaluate Ungrouped MAXIMUM AGGREGATE. 
FROM TABLE 
w_getdate 
Nested iteration. 
Table Scan. 
Forward scan. 
Positioning at start of table. 
Using I/O Size 2 Kbytes for data pages. 
With LRU Buffer Replacement Strategy for data pages. 
STEP 2 
The type of query is INSERT. 
The update mode is deferred. 
TO TABLE 
w_getdate 
Using I/O Size 2 Kbytes for data pages. 
QUERY PLAN FOR STATEMENT 11 (at line 47). 
STEP 1 
The type of query is SELECT. 
FROM TABLE 
l_dealuser 
Nested iteration. 
Index : deus_user 
Forward scan. 
Positioning by key. 
Keys are: 
f_user  ASC 
Using I/O Size 2 Kbytes for index leaf pages. 
With LRU Buffer Replacement Strategy for index leaf pages. 
Using I/O Size 2 Kbytes for data pages. 
With LRU Buffer Replacement Strategy for data pages. 
FROM TABLE 
f_sum 
Nested iteration. 
Index : sum_deal 
Forward scan. 
Positioning by key. 
Index contains all needed columns. Base table will not be read. 
Keys are: 
f_deal  ASC 
Using I/O Size 2 Kbytes for index leaf pages. 
With LRU Buffer Replacement Strategy for index leaf pages. 
QUERY PLAN FOR STATEMENT 12 (at line 56). 
STEP 1 
The type of query is SELECT. 
Evaluate Ungrouped MAXIMUM AGGREGATE. 
FROM TABLE 
w_getdate 
Nested iteration. 
Table Scan. 
Forward scan. 
Positioning at start of table. 
Using I/O Size 2 Kbytes for data pages. 
With LRU Buffer Replacement Strategy for data pages. 
STEP 2 
The type of query is INSERT. 
The update mode is deferred. 
TO TABLE 
w_getdate 
Using I/O Size 2 Kbytes for data pages. 
QUERY PLAN FOR STATEMENT 13 (at line 61). 
STEP 1 
The type of query is INSERT. 
The update mode is direct. 
Worktable1 created for REFORMATTING. 
FROM TABLE 
l_dealuser 
Nested iteration. 
Index : deus_user 
Forward scan. 
Positioning by key. 
Keys are: 
f_user  ASC 
Using I/O Size 2 Kbytes for index leaf pages. 
With LRU Buffer Replacement Strategy for index leaf pages. 
Using I/O Size 2 Kbytes for data pages. 
With LRU Buffer Replacement Strategy for data pages. 
TO TABLE 
Worktable1. 
STEP 2 
The type of query is SELECT. 
FROM TABLE 
f_sum 
Nested iteration. 
Table Scan. 
Forward scan. 
Positioning at start of table. 
Using I/O Size 2 Kbytes for data pages. 
With LRU Buffer Replacement Strategy for data pages. 
FROM TABLE 
Worktable1. 
Nested iteration. 
Using Clustered Index. 
Forward scan. 
Positioning by key. 
Using I/O Size 2 Kbytes for data pages. 
With LRU Buffer Replacement Strategy for data pages. 
QUERY PLAN FOR STATEMENT 14 (at line 70). 
STEP 1 
The type of query is SELECT. 
Evaluate Ungrouped MAXIMUM AGGREGATE. 
FROM TABLE 
w_getdate 
Nested iteration. 
Table Scan. 
Forward scan. 
Positioning at start of table. 
Using I/O Size 2 Kbytes for data pages. 
With LRU Buffer Replacement Strategy for data pages. 
STEP 2 
The type of query is INSERT. 
The update mode is deferred. 
TO TABLE 
w_getdate 
Using I/O Size 2 Kbytes for data pages. 
QUERY PLAN FOR STATEMENT 15 (at line 72). 
STEP 1 
The type of query is SELECT. 
FROM TABLE 
w_getdate 
Nested iteration. 
Table Scan. 
Forward scan. 
Positioning at start of table. 
Using I/O Size 2 Kbytes for data pages. 
With LRU Buffer Replacement Strategy for data pages. 
Parse and Compile Time 1. 
SQL Server cpu time: 100 ms.
Total writes for this command: 0 
Execution Time 0. 
SQL Server cpu time: 0 ms.  SQL Server elapsed time: 0 ms.
Table: w_getdate scan count 0, logical reads: (regular=0 apf=0 total=0), physical reads: (regular=0 apf=0 total=0), apf IOs used=0 
Table: w_getdate scan count 1, logical reads: (regular=1 apf=0 total=1), physical reads: (regular=0 apf=0 total=0), apf IOs used=0 
Total writes for this command: 0 
Execution Time 0. 
SQL Server cpu time: 0 ms.  SQL Server elapsed time: 0 ms.
Table: w_getdate scan count 0, logical reads: (regular=1 apf=0 total=1), physical reads: (regular=0 apf=0 total=0), apf IOs used=0 
Table: w_getdate scan count 1, logical reads: (regular=1 apf=0 total=1), physical reads: (regular=0 apf=0 total=0), apf IOs used=0 
Total writes for this command: 0 
Execution Time 0. 
SQL Server cpu time: 0 ms.  SQL Server elapsed time: 0 ms.

f_sum
118076828
118076829
118076830
118076835
118076836
118076837
118076838
118076839
118076840
118076841
118076842
118076843
118077536
118077537
118077538
118077539
118077540
118077541
118077548
118077550
118077549
118077552
118077551
118077553
Table: l_dealuser scan count 1, logical reads: (regular=4 apf=0 total=4), physical reads: (regular=0 apf=0 total=0), apf IOs used=0 
Table: f_sum scan count 8, logical reads: (regular=21 apf=0 total=21), physical reads: (regular=0 apf=0 total=0), apf IOs used=0 
Total writes for this command: 0 
Execution Time 0. 
SQL Server cpu time: 0 ms.  SQL Server elapsed time: 0 ms.
Table: w_getdate scan count 0, logical reads: (regular=1 apf=0 total=1), physical reads: (regular=0 apf=0 total=0), apf IOs used=0 
Table: w_getdate scan count 1, logical reads: (regular=1 apf=0 total=1), physical reads: (regular=0 apf=0 total=0), apf IOs used=0 
Total writes for this command: 0 
Execution Time 0. 
SQL Server cpu time: 0 ms.  SQL Server elapsed time: 0 ms.
The sort for Worktable1 is done in Serial   

f_sum
118076828
118076829
118076830
118076835
118076836
118076837
118076838
118076839
118076840
118076841
118076842
118076843
118077548
118077550
118077552
118077549
118077551
118077553
118077536
118077537
118077538
118077539
118077540
118077541
Table: l_dealuser scan count 1, logical reads: (regular=4 apf=0 total=4), physical reads: (regular=0 apf=0 total=0), apf IOs used=0 
Table: f_sum scan count 1, logical reads: (regular=74476 apf=0 total=74476), physical reads: (regular=0 apf=0 total=0), apf IOs used=0 
Table: Worktable1  scan count 624542, logical reads: (regular=1249110 apf=0 total=1249110), physical reads: (regular=0 apf=0 total=0), apf IOs used=0 
Total writes for this command: 114 
Execution Time 28. 
SQL Server cpu time: 2800 ms.  SQL Server elapsed time: 2840 ms.
Table: w_getdate scan count 0, logical reads: (regular=1 apf=0 total=1), physical reads: (regular=0 apf=0 total=0), apf IOs used=0 
Table: w_getdate scan count 1, logical reads: (regular=1 apf=0 total=1), physical reads: (regular=0 apf=0 total=0), apf IOs used=0 
Total writes for this command: 0 
Execution Time 0. 
SQL Server cpu time: 0 ms.  SQL Server elapsed time: 0 ms.

f_deal
40667661
40667661
40667661
40667663
40667663
40667663
40667664
40667664
40667664
40667665
40667665
40667665
40667699
40667699
40667699
40667700
40667700
40667700
40667703
40667703
40667703
40667704
40667704
40667704
Table: l_dealuser scan count 1, logical reads: (regular=4 apf=0 total=4), physical reads: (regular=0 apf=0 total=0), apf IOs used=0 
Table: f_sum scan count 8, logical reads: (regular=10 apf=0 total=10), physical reads: (regular=0 apf=0 total=0), apf IOs used=0 
Total writes for this command: 0 
Execution Time 0. 
SQL Server cpu time: 0 ms.  SQL Server elapsed time: 0 ms.
Table: w_getdate scan count 0, logical reads: (regular=1 apf=0 total=1), physical reads: (regular=0 apf=0 total=0), apf IOs used=0 
Table: w_getdate scan count 1, logical reads: (regular=1 apf=0 total=1), physical reads: (regular=0 apf=0 total=0), apf IOs used=0 
Total writes for this command: 0 
Execution Time 0. 
SQL Server cpu time: 0 ms.  SQL Server elapsed time: 0 ms.

f_deal
40667661
40667661
40667661
40667663
40667663
40667663
40667664
40667664
40667664
40667665
40667665
40667665
40667699
40667699
40667699
40667700
40667700
40667700
40667703
40667703
40667703
40667704
40667704
40667704
Table: l_dealuser scan count 1, logical reads: (regular=4 apf=0 total=4), physical reads: (regular=0 apf=0 total=0), apf IOs used=0 
Table: f_sum scan count 8, logical reads: (regular=10 apf=0 total=10), physical reads: (regular=0 apf=0 total=0), apf IOs used=0 
Total writes for this command: 0 
Execution Time 0. 
SQL Server cpu time: 0 ms.  SQL Server elapsed time: 0 ms.
Table: w_getdate scan count 0, logical reads: (regular=1 apf=0 total=1), physical reads: (regular=0 apf=0 total=0), apf IOs used=0 
Table: w_getdate scan count 1, logical reads: (regular=1 apf=0 total=1), physical reads: (regular=0 apf=0 total=0), apf IOs used=0 
Total writes for this command: 0 
Execution Time 0. 
SQL Server cpu time: 0 ms.  SQL Server elapsed time: 0 ms.
The sort for Worktable1 is done in Serial   

f_sum
118076828
118076829
118076830
118076835
118076836
118076837
118076838
118076839
118076840
118076841
118076842
118076843
118077548
118077550
118077552
118077549
118077551
118077553
118077536
118077537
118077538
118077539
118077540
118077541
Table: l_dealuser scan count 1, logical reads: (regular=4 apf=0 total=4), physical reads: (regular=0 apf=0 total=0), apf IOs used=0 
Table: f_sum scan count 1, logical reads: (regular=74476 apf=0 total=74476), physical reads: (regular=0 apf=0 total=0), apf IOs used=0 
Table: Worktable1  scan count 624542, logical reads: (regular=1249110 apf=0 total=1249110), physical reads: (regular=0 apf=0 total=0), apf IOs used=0 
Total writes for this command: 95 
Execution Time 27. 
SQL Server cpu time: 2700 ms.  SQL Server elapsed time: 2720 ms.
Table: w_getdate scan count 0, logical reads: (regular=1 apf=0 total=1), physical reads: (regular=0 apf=0 total=0), apf IOs used=0 
Table: w_getdate scan count 1, logical reads: (regular=1 apf=0 total=1), physical reads: (regular=0 apf=0 total=0), apf IOs used=0 
Total writes for this command: 0 
Execution Time 0. 
SQL Server cpu time: 0 ms.  SQL Server elapsed time: 0 ms.

num
1
2
3
3
4
5
Table: w_getdate scan count 1, logical reads: (regular=1 apf=0 total=1), physical reads: (regular=0 apf=0 total=0), apf IOs used=0 
Total writes for this command: 0 
Execution Time 0. 
SQL Server cpu time: 0 ms.  SQL Server elapsed time: 0 ms.

*/
...
Рейтинг: 0 / 0
30.01.2009, 00:20
    #35786827
кскнщ
Гость
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
ASE 12.5.1 висит перекресный запрос
Попробуйте так
Код: plaintext
1.
2.
3.
4.
5.
6.
7.
SELECT
           f_sum.f_sum
   FROM
           l_dealuser,
           f_sum (index sum_deal)
   WHERE
           l_dealuser.f_deal = f_sum.f_deal AND
           l_dealuser.f_user = @f_user

Если хинты не нравятся можно в индекс sum_deal добавить поле f_sum чтобы повысить привлекательность индекса. Кстати индексы на таблицы вы не привели.
...
Рейтинг: 0 / 0
30.01.2009, 10:25
    #35787259
Badger
Участник
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
ASE 12.5.1 висит перекресный запрос
кскнщЕсли хинты не нравятся можно в индекс sum_deal добавить поле f_sum чтобы повысить привлекательность индекса. Кстати индексы на таблицы вы не привели.Огромное спасибо. Помогло, когда был создн дополнительный индекст с первичным ключем - f_sum
Код: plaintext
1.
2.
CREATE NONCLUSTERED INDEX sum_deal_sum
    ON dbo.f_sum(f_deal, f_sum)
go
никогда так не делал....

Код: plaintext
1.
2.
3.
4.
5.
6.
7.
    SELECT
           f_sum.f_sum
      FROM
           l_dealuser,
           f_sum (index sum_deal_sum)
     WHERE
           l_dealuser.f_deal = f_sum.f_deal AND
           l_dealuser.f_user = @f_user
Индексы действительно не привел, они ниже, но вы указали правильно название! Мое уважение, и задача решена, еще раз огромное спасибо, вчера целый день на это убил.

Индексы--------------------------------------------------------------------------------
-- DBArtisan Schema Extraction
-- FILE : akvilon.sql
-- DATE : 30.01.2009 10:01:04.894
-- DATASOURCE : akvilon (Sybase)
-- VERSION : Adaptive Server Enterprise/12.5.1/EBF 11665 ESD#2/P/NT (IX86)/OS 4.0/ase1251/1838/32-bit/OPT/Fri Feb 20 04:11:31 2004
-- TARGET DB : akvilon
--------------------------------------------------------------------------------

--
--CREATE INDEXES
--
CREATE NONCLUSTERED INDEX sum_deal
ON dbo.f_sum(f_deal)
go

CREATE INDEX sum_date_type
ON dbo.f_sum(date_time,f_sumtype)
go

CREATE INDEX sum_date_time
ON dbo.f_sum(date_time)
go

CREATE INDEX sum_acc
ON dbo.f_sum(f_account)
go

CREATE INDEX sum_acc_date_time
ON dbo.f_sum(f_account,date_time)
go

CREATE INDEX sum_currency
ON dbo.f_sum(c_currency)
go

CREATE INDEX sum_type
ON dbo.f_sum(f_sumtype)
go

CREATE INDEX sum_kind
ON dbo.f_sum(c_sumkind)
go

CREATE INDEX sum_date_pay
ON dbo.f_sum(date_pay)
go

CREATE INDEX sum_date_pay_sumtype
ON dbo.f_sum(date_pay,f_sumtype)
go

CREATE INDEX sum_deal_currency
ON dbo.f_sum(f_deal,c_currency)
go

CREATE INDEX sum_user
ON dbo.f_sum(f_user)
go

CREATE INDEX sum_deal_sumtype
ON dbo.f_sum(f_deal,f_sumtype)
go
...
Рейтинг: 0 / 0
Форумы / Sybase ASA, ASE, IQ [игнор отключен] [закрыт для гостей] / ASE 12.5.1 висит перекресный запрос / 3 сообщений из 3, страница 1 из 1
Найденые пользователи ...
Разблокировать пользователей ...
Читали форум (0):
Пользователи онлайн (0):
x
x
Закрыть


Просмотр
0 / 0
Close
Debug Console [Select Text]