cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

First Query

7,216

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?)

View Entire Topic
Former Member
0 Likes

Walmir - how much memory have your machine and what is your command line to start server/db? if you have problem on first query after restart (and after that everything is fine), then it may be that on start there is in use to small -c XXX parameter for memory cache.

Have you tried to use Index Consultant (you can see as menu option it in ISQL)? Have you created all indexed suggested by Index Consultant?

An what is your version of ASA? i.e. ASA.12.0.1.XXXX

0 Likes

@JonJon Database test. I am using the ASA Database Engine Version 9.0.2.3951

-ch 2048M

tbsales the table has a clustered index

CREATE CLUSTERED INDEX "idx_datesale" ON "DBA"."TBsales" ( "EMP" ASC, "DATE_SALE" ASC ) IN "SYSTEM";

Intel(R) core(TM) i3 CPU 550 @3.20GHz 4 GB SO 64 Bits

VolkerBarth
Contributor
0 Likes

What does dbsrv9 -o MyLog.txt reveal when the database is started - how much cache is used by default (as you don't specify this via -c)?

If this is much lower than the 2 GB limit you have set with -ch, I'd second Jon's suggestion to add -c XM...

VolkerBarth
Contributor
0 Likes

Well, given the 1 GB default initial cache size

1029920K of memory used for caching

and a rather low disk fragmentation

Performance warning: Database file "c:intesigoba-obaMirassolbdintesig.db" consists of 3 disk fragments

I don't think the cache size is the problem.

Does the slow execution also show up if you run "call sa_flush_cache()" before each query execution? - Then at least the problem may be due to a better usage of the cache contents for further runs...

0 Likes

I did a survey of some procedures to be performed / executed and followed the following steps:

• Change "Page Size": • Create a new database with 4096 bytes "Page Size". • Make unload / reload • Execute the command in isql: ALTER system dbspace ADD 512 MB;

• Reduce fragmentation: • If possible, place the database in a single partition on the hard drive. • Often run the disk defragmenter for Windows. • Defragment the file BDINTESIG.db when fragmented disks. (use the command in DOS: contig.exe "full_path_of_the_database")

• Cache Size • When starting the database using 2M cache and use the options "-1024M ch" (changed to this step-c2048M) 50% of RAM)

• Clear statistics • Run script to delete and recreate statistics.

Running "call sa_flush_cache()" still has slow, (only the first query)

***When I start the database with-c2048M displays the following message:

Note: A cache size of 2097152K exceeds the available physical memory of 1739876K. A performance penalty may result.

reimer_pods
Participant

To assign 50 percent of the available RAM you might use -c 50P.
Trying 2 GB or more won't do, if you're in a 32 bit environment. The ASA engine can't allocate more than ~ 1.8 GB due to the OS limits.

VolkerBarth
Contributor
0 Likes

Time to show the graphical plans of the slow and fast query executions, I'd think...

0 Likes

how to get the execution plan for the query in the asa-9? I want to generate a file that I can edit it.

0 Likes

Hi,

Working with an ERP that features integration with Inventory, Sales, bank, cash, documents payable, receivable documents, accounting, tax paying employees. And every now and then is always showing signs of sluggishness in queries. Some here have suggested deleting some data (say the database is too "bloated"), but I do not think so because the databases have averaged about 3GBytes the 5GBytes.

To implement the Index Consultant. Leave for 10 minutes and running already been captured 8500 queries. How long you must leave this option running?