stringlew 发表于 2011-01-05 15:31

andkylee ,请教建立索引问题

select workitemid, workitemname, actionurl, processinstid from WFWorkItem where currentstate=10 and participant="2" order by workitemid desc。

以上sql,在sybase15.03中,如何建立索引。

目前查询计划如下:

QUERY PLAN FOR STATEMENT 1 (at line 1).


    STEP 1
      The type of query is SELECT.

        2 operator(s) under root

       |ROOT:EMIT Operator (VA = 2)
       |
       |   |SORT Operator (VA = 1)
       |   | Average Row width is 36.250000
       |   | Using Worktable1 for internal storage.
       |   |
       |   |   |SCAN Operator (VA = 0)
       |   |   |FROM TABLE
       |   |   |WFWorkItem
       |   |   |Index : IDX_WFWI_PARTICI
       |   |   |Forward Scan.
       |   |   |Positioning by key.
       |   |   |Keys are:
       |   |   |    participant ASC
       |   |   |Using I/O Size 16 Kbytes for index leaf pages.
       |   |   |With LRU Buffer Replacement Strategy for index leaf pages.
       |   |   |Using I/O Size 16 Kbytes for data pages.
       |   |   |With LRU Buffer Replacement Strategy for data pages.

目前25W数据,大约需要1秒的时间才能完成。该表的数据会持续增长,导致时间会越来越长。

IDX_WFWI_PARTICI 此索引基于 participant 字段,没有排序。

andkylee 发表于 2011-01-05 18:29

currentstate和participant应该都是选择性(区分度)不好的列。

你需要综合考虑, 是否在currentstate和participant这两列上建立组合索引。 组合索引中列的顺序需要介乎其他SQL。


你用的是16k的逻辑页面吧。配置一个大IO命名缓存池。

stringlew 发表于 2011-01-06 14:27

建立组合索引,IO命名缓冲池为3000M。有些许效果,在单条sql运行上,提升比较明显。

同时更新的其他表均绑定到同一命名缓冲池中。

同时做更新插入的还有另外4张表,已经删除其中的无用的索引,目前只留下主键索引。

是否应该建多个缓冲池,然后分开绑定?内存8G。该如何分配。
页: [1]
查看完整版本: andkylee ,请教建立索引问题