Index on the date column

Hello

I have a behavior when running a table with an indexed column date that seems a bit away from me.

I have a table with many columns and rows 4.8 million (Oracle 11 g 2). One of his columns is of data type Date. This column is indexed using a b-three index.

Consider the select statement. It returns only 32 thousand rows (less than 1% of the number of rows in the table). Oracle did a full scan to run the query.

Field2 can be any column of the table that is not part of the index (for example, a column which is varchar2 (14)).

As the used filter has a high selectivity, I expect Oracle to use the index on the date_field when executing the query. Have no idea about it? Is there a rule on the date columns indexing?

Select Field2
TABLE
WHERE date_field > = TO_DATE('13/09/2010','DD/MM/YYYY')
and date_field < TO_DATE('14/09/2010','DD/MM/YYYY')

user492400 wrote:
The clustering_factor is not too high?

OBJECT_TYPE-> INDEX
BLEVEL-> 2
LEAF_BLOCKS-> 14796
DISTINCT_KEYS-> 3249780
AVG_LEAF_BLOCKS_PER_KEY-> 1
AVG_DATA_BLOCKS_PER_KEY-> 1
CLUSTERING_FACTOR-> 3620372
NUM_ROWS-> 4823298

If you look at your plan, it has a cost of 11156.

The CBO estimated 29446 lines will be returned. It's a selectivity of 29446/4823298, which represents 0.61%.

Therefore, the cost of using the index is approximately:

2 (blevel) + 0.61% of the 14796 (pads of sheets) + 0.61% 3620372 (clustering factor) which is about 22195 (assuming that CBO based default settings).

22195 is superior (so much) than 11156 so Full Table Scan WINS.

See you soon

Richard Foote
http://richardfoote.WordPress.com/

Tags: Database

Similar Questions

  • How to insert the date column for the new line of adf BC tester.

    Hello

    JDeveloper version 11.1.1.5.0

    I have a table with a DATE column. I'm trying to insert a new row in the table of the BC ADF tester. While providing a value for the DATE column, I am struck the below error:

    (oracle.jbo.domain.DataCreationException) Houston-25009: failed to create an object of type: oracle.jbo.domain.Date type: java.lang.String with value: 2011/12/06

    Please let me know what should be the format to specify the date when inserting input value using the tester of BC.

    Thank you
    Rouhaud

    Roudier,
    You can determine the format of date by yourself.
    in your entity object select the attribute, click on edit, go to the control indicators, the Format type, select Date Simple
    and in the format field, you can enter the format you need
    as YYYY/MM/DD

  • Parent index for the data in a table?

    Is there a way to index a child table with a function to include a column from a parent table?

    Example:

    I want to see how many children live in a zip code (and their address is listed with their parents)

    Select count (*)

    class c of child, parent p

    where c.parent_id = p.parent_id

    and p.zipcode = "12345"

    Is there a way to make an index of children with a function that gets parents zip code?

    Thanks for the help?

    An index on the child table can reference only the columns of the child table.  You can't have an index on the child table that is based on information from the parent table.

    There are the function-based index, but they may involve only constants and deterministic functions (and, of course, the columns of the table).  For example, the child table could have a clue on UPPER (name), where last_name is a column of the table, but he could not have a clue about get_zip (parent_id), where get_zip is a function defined by the user who queries the parent table.

    Well - you "might" have a functional indication if you did to be deterministic, but it is not recommended because if the changed zip_code parent would really not deterministic and the change would not be included in the index.

    This apart from this code will work properly if the zip_code data does not change:

    CREATE TABLE parent (COL1 number primary key, zip VARCHAR2 (5))
        
    create the child table (col1 number, parent_key number);

    create or replace function get_zip (number p_key) return deterministic varchar2 as
    v_zip varchar2 (5);
    Start
    Select zip from v_zip of the parent where col1 = p_key;
    Return v_zip;
    end;

    /

    create indexes on children (get_zip (parent_key)) child_zip;

  • Data external to appear as the date column

    Hello

    I have an external table that gets a column called time_stamp in the external table as varchar (I know, bad), is there a way to turn in date with the time when the external table definition? or can I have a query with the to_date function to overcome the problem?

    column

    14/01/2014 11:20:43

    Thank you very much.

    the foregoing transforms col3 in date format, but displays the following value in the external table: 14 January 14, it should be mm-dd-yyyy

    Do you mean when you query the external table?

    Dates (stored as DATE data type) have no "format".

    If you want the string to a date column representation in a specific format, and then set your NLS settings (setting NLS_DATE_FORMAT) accordingly.

    Edit:

    Don't forget to change the data type in the column as well list, otherwise you will get an implicit conversion that could also explain the issue:

    create table my_ext_table)

    col1 number (8)

    , col2 VARCHAR2 (3)

    col3 date

    )

    (external) Organization

    ...

  • Change the Date column tabular database of dd/mm/yyyy to dd/mm/yyyy

    Hi, I use Jdeveloper 11 G with an Oracle database.

    My table is empty now, but I am importing some excellent columns inside and dates to throw errors because you have some dates like 14/09/2012, which means the month is out of reach even if it is not.

    This seems to be a simple thing to do, but I was unable to find how online.

    Help, please

    Table import stuff using SQL Developer - most things in JDeveloper db is in reality.

    What you need to do is to indicate what date format is for incoming data - which allows us to build the inserts properly to the Import Wizard.

    Here's a tutorial to take you through the steps
    http://www.thatjeffsmith.com/archive/2012/04/how-to-import-from-Excel-to-Oracle-with-SQL-Developer/

    Special attention to this screenshot
    http://thatjeffsmith.wpengine.com/wp-content/uploads/2012/04/excel_copy9.PNG

    You want to enter the date format, because it is in the spreadsheet.

  • Comparing converted text until then with the Date column

    I have a question where I need out of a text column in a date format and then compare this column against another column in the same table, which is already to date format. I tried to use a sub query to avoid doing this in two steps, but get a:

    "ORA-01858' a non-digit character was found here where was waiting for digital"

    error message that obviously has something to do with the date formatting in the subquery: the types do not match.

    Note: clock_num is a text column and contains the numbers are supposed to be dates like 070111 - where the need for conversion to a date type to match the stat_date which is the type of date column. I have no control over the data in this column. It is not my picture, is the picture of the society and I have to use!

    So my question is what syntax/function should I use to get the type of expression clock_nbr the type of eff_date.

    Or y at - it another way to do the same thing without using subquery?

    Any help is appreciated...

    SELECT
    me. SSN,
    Of
    member_enroll me
    WHERE me.ssn = '999999999'
    AND me.stat_date <
    (SELECT to_date (substr (me.clock_num, 1, 2) |)) » /' || substr (me.clock_num, 3, 2) | '/' || substr(me.clock_num,5,2), 'mm-DD-yy') as clock_nbr
    OF member_enroll me
    WHERE me.ssn = '999999999')

    I have no experience with PL/SQL Developer. Any chance you could launch SQL * more and copy / paste of a session where you run this code?

    You should only run the DDL to create the function once. If the second query runs, you have managed to successfully create the function. My hypothesis is that whatever 'window SQL' you are talking about and what you mean by 'run' is the cause only the function must be created. Most of the IDEs have a function to execute current SQL statement, without taking into account other statements that can be registered in the same window, and a separate function to execute all instructions in the current window. Different iDEs have different requirements to separate several SQL statements if you want to run all of the SQL statements in a window. You may need to do something like the added statement a / after the CREATE FUNCTION as a separator.

    Justin

  • filling of datetime column SQL Server with the data in the date column oracle

    After a lot of "finangling", I think I have my link dg4msql works well between Oracle and MSSQL.

    Now, what I'm trying to do, is fill a table in MSSQL with an Oracle table column values, whenever a new row is inserted in the Oracle table. I use a very simple trigger on the oracle table that goes basically like this:

    mware is dblink to MSSQL database, oracle col worth DATE and mssql col is of type DATETIME

    This is the relaxation: (edited to show only the column in question)
    ==================================================================================
    CREATE or replace TRIGGER < oracleowner >. INSERT_INTO_NVDB
    AFTER INSERT ON < oracleowner >. < oracletable > for each row
    BEGIN
    insert into '< mssqlowner > '. «< mssqltable > @mware «»
    (
    "load_date_time,"
    )
    VALUES)
    : new.loading_date,.
    );

    END;
    ==================================================================================

    Now, when you enter a record in the Oracle trigger triggers ok table but does not insert a date in the MSSQL table, the 'load_date_time' in the mssql table can have NULL values so I guess there just inserts a null value.

    When I activate the triggers on the table MSSQL, which then takes these values and inserts them into another table with values from other tables, inserting in the Oracle table fails because the relaxation on the MSSQL database tries to pass the date (which is empty) table MSSQL in another table where the datetime field is not null.

    I guess it's because Oracle date format is not compatible with MSSQL, which I think is "yyyy-mm-dd hh: mm:"- so I have to either convert the date format by default Oracle to match a MSSQL, or convert a char of the trigger value. (The developer of the side MSSQL says if I can convert it to a char value that should be ok too)

    I think that it is probably better to leave it in the date format, the best way to do this would be to put an "alter session set nls_date_format ="at the beginning of the trigger?

    Can I convert the date to char the trigger easily? If there is a better way to proceed in the way I approach it I'm all for it.

    Thank you!

    Hello
    Your best option is to explicitly convert dates Oracle in a format recognized by SQL * Server. It's more coding, but then you know exactly what is being inserted and you give more control, if anything changes. You can also code to handle null data.
    I'm not sure than to try to change the format of date to 'alter session... ". "do what you want.
    You can use "to_char" on a date into character data-

    To_char (, "HH24:MI:SSxFF of MON-DD-YYYY")

    and use any mask format supported.
    You also use 'to_date' to transform the character data in a date format, as well as 'to_char' and 'to_date' in combination.
    For example -.

    SELECT TO_CHAR (TO_DATE (October 27, 98 ',' DD-MON-RR'), 'YYYY') 'Year' FROM DUAL;

    This is all discussed in the documentation-

    Oracle® database
    SQL language reference
    11g Release 2 (11.2)

    where it also describes the different format masks.
    If you need further assistance on the use of to_date, to_char formats then ask in the forum SQL/PLSQL.

    SQL and PL/SQL

    where they have more experience.

    Kind regards
    Mike

  • Change the Jpeg file taken time in the "Date" column to windows explorer for modification time?

    I just found out that JPEGs, edited and recorded by CS4 still wear their original creation time in windows Explorer, regardless of how many times they have been modified, which makes it very inconvenient and confusing, without opening the files to find out. Does anyone know how to change the setting to 'Update?' Thank you very much in advance!

    You say that you see the creation Date column in Windows Explorer, but not update?

    If this is the case, it's an easy fix...  In Windows Explorer, right click on the bar with the titles (for example, on the title the creation Date) and check the update box.  Normally the update, this is what is displayed by default Explorer for the elements of the General.  I don't know what is shown for other types of files, I use only general articles.

    What do you see when you follow these steps:

    1. right click on the folder that contains your images (in the navigation to the left).

    2. Select Properties.

    3. click on the Customize tab.

    4 what was the optimize this folder for: of the field?

    FYI, as you can see you can change folder for example, customizing the general articles for one or a whole folder tree.

    You can also make changes to one of your folders of photos, and then propagate the settings to all folders of this type in your system.  I'm really jump coming here; I would like to know if that's what you eventually want to do.

    -Christmas

  • To add minutes in the Date column

    Hello..

    I just wan to calculate the date with timestamp after addition of minutes.
    I had the time (date column), I wan to calculate the column date of to_time according to the minutes, we added time (date column).

    can u please help me... As soon as possible...

    Hello

    It would have been better if you would have given a sample input and output. So to add a minute

    update table xyz set to_time = from_time + (number of minutes)/24/60 
    

    Something as above can be done.

    Concerning
    Anurag

  • Calculate number of week in the Date column

    Hello friends,

    I tried to find the solution for the calculation of the number of week and the closest, I arrived at is - it
    Select to_char (to_date('29.12.2009','dd.mm.yyyy'), 'WW') of double;

    Can someone help me pls with code to calculate a Date_Column week numbers?


    Thank you!!

    worried Abt was only the part to_date

    Don't worry not at all on this subject, it is perfectly 'by the book' ;)
    With the help of TO_DATE, you said Oracle to treat your value as a DATE instead of a STRING.
    Now, it is exactly what you needed to do.
    And using TO_CHAR with your format after that mask, you'll find yourself with the right answer to your query.

    If your column is already the DATE data type, then you don't need the TO_DATE, and you can use:

     select to_char(your_date_column,'WW') from your_table;
    

    Right away.

  • Problem in the search using the Date column

    Hello

    I use the date in the search for field (jj-LUN-AA date selector) P1_END_DATE.

    When I search the record he won't give the result.
    I used the following in the where condition

    trunc (e.END_DATE) = trunc (to_date (:P1_END_DATE))

    Please notify.

    Concerning
    Harinder

    Harinder salvation,

    Make sure that you use the same date format as your date picker.
    Do not assume that they will be the same.
    TO_DATE (: PXX_XXX, ' dd/mm/yyyy');

    Concerning

    Michael

  • How to set a text index in the Data Modeler

    Hello

    How to set a text index (indextype is ctxsys.context) in data maker?

    The SQL command would be:

    create index P1_TEXT_BESCHR_SPRACHE on indextype P1_PDM_MODUL_SPRACHE (DESCRIPTION) is ctxsys.context
    parameters ("lexer global_lexer language format column FORMAT STORAGE PDMSTORE")
    Online
    /


    Thanks in advance for any help.

    Monika

    Hi Monika,

    After you create the relational model, you create a physical. In the physical model there is dialog box properties index, where you can set the properties of context index.

  • Oracle index on the specified columns

    Hello

    I read Oracle index to improve the performance of database engines when searching for data.
    Therotically I know, but practically, did not write all the indexes in fact.

    For example, we have a lower index in our Application:


    CREATE a UNIQUE M_Index INDEX on F_SECTION ("FMAT_ID", "SECT_NAME")

    PCTFREE, INITRANS 10 2 MAXTRANS 255

    STORAGE (INITIAL NEXT 16384 16384 MINEXTENTS 1 MAXEXTENTS 121)
    PCTINCREASE 50 FREELISTS 1 FREELIST GROUPS 1 DEFAULT USER_TABLES)
    TABLESPACE 'SYSTEM '.



    I saw here for questioning, this table F_SECTION consists of several columns under him, but someone please tell me why is that the Index has been created according to only the columns.

    waiting for your ideas, thank you in advance.

    Hello

    I read Oracle index to improve the performance of database engines when searching for data.
    Therotically I know, but practically, did not write all the indexes in fact.

    For example, we have a lower index in our Application:

    CREATE a UNIQUE M_Index INDEX on F_SECTION ("FMAT_ID", "SECT_NAME")

    PCTFREE, INITRANS 10 2 MAXTRANS 255

    STORAGE (INITIAL NEXT 16384 16384 MINEXTENTS 1 MAXEXTENTS 121)
    PCTINCREASE 50 FREELISTS 1 FREELIST GROUPS 1 DEFAULT USER_TABLES)
    TABLESPACE 'SYSTEM '.

    Hello

    During the design phase of database, the database modelers would have done the combination of 'FMAT_ID' and 'SECT_NAME' as primary key that uniquely identifies the record in your table.

    Kind regards
    Claudy

  • How to get the index of the list column Mult box

    Hi all

    I need little help. Please help me.

    Is there is no property to dynamically change the index position of line "Multi column list box"?

    I want to change the index location when running as below.

    He called the top left cell Visible. There is no as many properties.

  • Creating indexes in the XMLType column

    Hello

    I have the following for XML document stored as an XMLType column.

    < ocaStatus xmlns = "http://xmlbeans.apache.org/ocastatus" > < status > < > 934 statusCode < / statusCode > < statusDate > Wed Apr 07 16:05:53 GMT + 05:30 2010 < / statusDate > < userId > u0121845 < / userId > < comment > sent to FLC < / comment > < / status > < status > < statusCode > 934 < / statusCode > < statusDate > Wed Apr 07 15:58:25 GMT + 05:30 2010 < / statusDate > < userId > u0121845 < / username > < Comment > sent to FLC < / comment > < / status > < status > < statusCode > 934 < / statusCode > < statusDate > Wed Apr 07 15:54:02 GMT + 05:30 2010 < / statusDate > < userId u0121845 > < / userId > < comment > sent to FLC < / comment > < / status > < status > < statusCode > 750 < / statusCode > < statusDate > 2010 - 03 - 31 12:39:41.580 GMT + 05:30 < / statusDate > < u0121845 userId > < / userId > < comment > metadata of the Document is correct. < / comment > < / status > < status > < statusCode > 934 < / statusCode > < statusDate > 2010 - 03 - 31 12:39:41.580 GMT + 05:30 < / statusDate > < userId > u0121845 < / userId > < comment > sent to FLC < / comment > < / status > < status > < statusCode > 932 < / statusCode > < statusDate > 2010 - 03 - 31 12:39:41.580 GMT + 05:30 < / statusDate > < userId > u0121845 < / username > < comment > loaded Novus < /. comment > < / status > < status > < > 700 statusCode < / statusCode > < statusDate > 2010 - 03 - 31 12:39:41.580 GMT + 05:30 < / statusDate > < userId u0121845 > < / userId > < comment > Document is deleted from the OCA. < / comment > < / status > < / ocaStatus >

    I created as a result of the clues in the XML
    CREATING INDEX 'OCA_DEV '. "' OCA_STATUS_CODE_INDEX ' ON 'OCA_DEV '. "DOCUMENT_STATUS_XML"(EXTRACTVALUE('/ocaStatus/status/statusCode'));
    CREATING INDEX 'OCA_DEV '. "' OCA_STATUS_DATE_INDEX ' ON 'OCA_DEV '. "DOCUMENT_STATUS_XML"(EXTRACTVALUE('/ocaStatus/status/statusDate'));

    However, the problem is that I will be having several status within each XML that violates the indexing.
    Is there a way I can still create indexes for multiple State values in each XML file?

    Thanks in advance.

    Hello

    Take a look at the manual xdb (which version do you use?), for the 10.2 version, see: http://download.oracle.com/docs/cd/B19306_01/appdev.102/b14259/xdb04cre.htm#sthref596
    It describes how you can index an XMLTYPE. Because you describe how you use, take a look at your needs.

    In 11G, you have the XMLINDEX to xmltypes indexing, you will find information here: http://download.oracle.com/docs/cd/E11882_01/appdev.112/e10492/xdb_indexing.htm#CHDFCGGI

    Herald tiomela
    Superconsult.nl

Maybe you are looking for