Forum Stats

  • 3,827,763 Users
  • 2,260,818 Discussions


Partition vs Bitmap

i currently learning database administration and i wanted to ask on what scenario do we need to create a partition?

from what i know we create a bitmap index on column that have low disctinct value(gender,marital status,etc) and there is a query that have 1 or more predicate using those low distinct value column

for example

select * from employees where gender='M' and marital_status ='Married'

and for the partition we create it in order to prevent oracle to do a FTS when our query return most of the row in the table. instead oracle can just read from a partition

for example assuming emp have 1k record(200 M 800 F)

select * from employees where Gender='F';

with this query the optimizer will opting for fts because our query return 80% of the row.and it is good to create a list partition here based on gender. does this method efficient on performace tuning? can anyone tell on what scenario we create a partition?



  • Mike Kutz
    Mike Kutz Member Posts: 6,195 Silver Crown
    edited Jan 4, 2022 10:56AM


    Bitmap indexes implies Serialization. That's like having the db parameter _SLOW=TRUE.

    It can speed up SELECTS, but at a cost for other DML operations.

    In my uses, it's not about the "low cardinality" of the answers in a column, but the "low cardinality" of your query results.

    Eg finding out that a particular song, sung by Adam Sandler about Tinder results for other Eskimos in his tribe, is true

    I've used them to speed up ad hoc queries on final reporting tables.

    Billy uses them to show you can count 42B rows in under 1s.


    "Prevent FTS" is one use for Partitions.

    The primary use I've seen is for data management.

    Need to remove 1 mo worth of data? Drop a Partition

    Also, research ILM in the Data warehouse guide. This helps automate the task of moving chunks of old data for you. (Eg move 1mo worth of 3yr old data from tablespace on SSD to compressed read-only tablespace on SATA)

  • User_JNHXJ
    User_JNHXJ Member Posts: 14 Green Ribbon

    Thank for replying mike

    i have a couple of question

    1.what u mean by ad hoc query is query using bind variable in where clause? or is there a different meaning?(from what i know ad hoc query is a type of query where result set is depent on the value supplied to a variable)

    2."Need to remove 1 mo worth of data? Drop a Partition" even if we drop a partition the actual table still have the data from that partition right? and for what purpose we dropping this data? for memory or just deleting old data?

  • Mike Kutz
    Mike Kutz Member Posts: 6,195 Silver Crown

    Ad hoc

    This is what most end users want to perform.

    APEX IR searches are ad hoc queries. Especially those faceted searches.

    Bitmap indexes could drastically improve multi-column queries of these types even on a 1 B row table.

    But, INSERT/UPDATE/DELETES would be horrible. You'll want to do infrequent bulk operations from a single transaction only. Tools like DBMS_PARALLEL_EXECUTE will cause the crud operation to take longer if parallel_level is higher than 1. (I learned this the hard way)

    Drop Partition

    You usually remove old data for legal reasons.

    Partitions are individuals tables magically joined together to act as 1 table. If you read the history of Oracle, Partitions started in v7.3 as Partitioned VIEWs.

    So, when you DROP a Partition, you are actually dropping a table.

    Which then brings up Partition EXCHANGE. In this case you are actually swapping one table for another. And because the DD is only swapping the pointers, this is extremely fast.

    You can swap in/out a table's worth of data in the blink of an eye. (I'm ignoring INDEXES)

    Again, I find Partitions more useful for data management. But queries performance shouldn't be ignored.

  • User_JNHXJ
    User_JNHXJ Member Posts: 14 Green Ribbon

    thanks for the partition part i got a little insigth about it.

    but still have question about bitmap

    can you explain example of  "faceted searches" is it like result set with low cardinality?(FYI first time hear faceted word so i do not understand)