Please be aware that the content in SAP SQL Anywhere Forum will be migrated to the SAP Community in June and this forum will be retired.

Hi Community,

a customer starts dbvalid every night on a 68 GB Backup of SQL Anywhere DB. Up to 20.7.2013 that takes 3 hours. Since 20.7.2003 it takes 12 to 15 hours. Increasing cache from 4 to 6 GB leads to duration of 10 hours. What can be the reason for this dramatically increase of time?

Some more information: Sql Anywhere 64 bit. VM, quad core, 2.93 GHz, Intel Xeon, Win2008 R2, 24 GB RAM. Backup-DB ist startet by: dbeng -c 6g -ca 0 . Validation is startet by: dbvalid -q -fx . During validation resource-monitor shows reading of dbeng by 53,000,000 B/min.

asked 26 Jul '13, 04:51

Steffen%20Winkler's gravatar image

Steffen Winkler
accept rate: 0%

53 MBytes per minute mean < 1MBytes per second, so just the reading of the DB file would last more than 18 hours. I would check the underlying IO system, maybe you have a degraded performance there.

permanent link

answered 26 Jul '13, 07:22

Martin's gravatar image

accept rate: 14%


I agree. With -fx, I believe most of the IO should be sequential since the index probes (which can require a lot of random IO if the cache is too small) would be skipped. Sequential IOs should be fast. Maybe another process in this VM or another VM was doing IOs to the same drive? That would introduce randomness to the IO and drastically lower performance.

(26 Jul '13, 08:07) John Smirnios

Copying the database to a "real" machine (not a VM), preferably with no other activity for that time, and running the validation there should give you the chance to compare results.

(26 Jul '13, 08:48) Reimer Pods

Thank you all, dbvalid on backup.db and productiv.db are running on the same server since years. We have to clearify with the local administrators if there are other processes in this VM or another VM that are doing IOs to the same drive.

(26 Jul '13, 09:03) Steffen Winkler

One wild guess is that the database was subject to some massive operation (deletes and inserts, for example) that suddenly caused it to become internally fragmented.

The builtin procedures sa_index_levels, sa_index_density, sa_table_fragmentation and sa_table_stats can be used to tell you if that is true. Here are two "value added" procedures that display columns named "concerns" and "fragmentation" to warn you of possible problems; the sample output comes from the V10 demo database (one "concern", no "fragmentation"):

CREATE PROCEDURE p_index_fragmentation ( IN @owner_name VARCHAR ( 128 ) )
RESULT ( table_name       VARCHAR ( 128 ),
         index_name       VARCHAR ( 128 ),
         rows             UNSIGNED BIGINT,
         leaf_pages       UNSIGNED INTEGER,
         levels           INTEGER,
         density          NUMERIC ( 8, 6 ),
         concerns         VARCHAR ( 100 ) )
SELECT sa_index_levels.TableName  AS table_name,
       sa_index_levels.IndexName  AS index_name,
       SYSTABLE.count             AS rows,
       sa_index_density.LeafPages AS leaf_pages,
       sa_index_levels.Levels     AS levels,
       sa_index_density.Density   AS density,
       STRING (
          IF levels > 2
             THEN 'deep'
             ELSE ''
          IF levels > 1 AND density < 0.5
             THEN IF levels > 2
                     THEN ', low density'
                     ELSE 'low density'
              ELSE ''
          ENDIF ) AS concerns
  FROM dbo.sa_index_levels ( owner_name = @owner_name )
       INNER JOIN dbo.sa_index_density ( owner_name = @owner_name )
               ON sa_index_density.TableName = sa_index_levels.TableName
              AND sa_index_density.IndexName = sa_index_levels.IndexName
               ON SYSTABLE.table_name = sa_index_density.TableName
 WHERE USER_NAME ( SYSTABLE.creator ) = @owner_name
 ORDER BY table_name,

CALL p_index_fragmentation ( 'GROUPO' ); -- ***** USE THE CORRECT OWNER NAME

'SalesOrderItems','FK_ProductID_ID',1097,3,2,0.456380,'low density'

CREATE PROCEDURE p_table_fragmentation ( IN @owner_name VARCHAR ( 128 ) )
RESULT ( table_name                  VARCHAR ( 128 ),
         rows                        UNSIGNED INTEGER,
         row_segments                UNSIGNED BIGINT,
         segments_per_row            NUMERIC ( 20, 4 ),
         table_pages                 UNSIGNED BIGINT,
         extension_pages             UNSIGNED BIGINT,
         rows_per_table_page         NUMERIC ( 20, 4 ),
         extension_pages_per_segment NUMERIC ( 20, 4 ) )

  INTO #sa_table_fragmentation
  FROM sa_table_fragmentation ( owner_name = @owner_name );

SELECT #sa_table_fragmentation.TableName     AS table_name,
       #sa_table_fragmentation.rows          AS rows,
       #sa_table_fragmentation.row_segments  AS row_segments,
       #sa_table_fragmentation.segs_per_row  AS segments_per_row,
       sa_table_stats.table_page_count       AS table_pages,
       sa_table_stats.ext_page_count         AS extension_pages,
       IF table_pages = 0
          THEN 0
          ELSE CAST ( rows AS NUMERIC ( 20, 4 ) ) 
             / CAST ( table_pages AS NUMERIC ( 20, 4 ) )
       ENDIF                                 AS rows_per_table_page,
       IF rows = 0
          THEN 0
          ELSE CAST ( extension_pages AS NUMERIC ( 20, 4 ) ) 
               / CAST ( row_segments AS NUMERIC ( 20, 4 ) )
       ENDIF                                 AS extension_pages_per_segment
  FROM #sa_table_fragmentation
       INNER JOIN sa_table_stats()
               ON sa_table_stats.table_name = #sa_table_fragmentation.TableName
 WHERE sa_table_stats.creator = @owner_name
 ORDER BY table_name;


SELECT table_name,
       IF rows >= 1000
       AND ( segments_per_row >= 1.05 
             OR extension_pages_per_segment >= 2 )
          THEN 'Fragmentation!'
          ELSE ''
       ENDIF AS fragmentation
  FROM p_table_fragmentation ( 'GROUPO' ) -- ***** USE THE CORRECT OWNER NAME
 ORDER BY table_name;

permanent link

answered 26 Jul '13, 06:34

Breck%20Carter's gravatar image

Breck Carter
accept rate: 20%

Thank you Breck,

unfortunately the connection was lost after 1 h waiting for result of CALL p_index_fragmentation

(26 Jul '13, 08:59) Steffen Winkler
Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text]( "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:


question asked: 26 Jul '13, 04:51

question was seen: 2,844 times

last updated: 26 Jul '13, 09:03