on ‎2013 Jan 09 7:16 AM
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?)
Request clarification before answering.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@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
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...
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.
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.
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?
| User | Count |
|---|---|
| 8 | |
| 5 | |
| 4 | |
| 4 | |
| 3 | |
| 3 | |
| 2 | |
| 2 | |
| 2 | |
| 2 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.