Key Index

Hi,
Is it possible to get the index of the key I inserted in berkeley? I need to know the arrangement of the keys I inserted. Are there methods in getting the index of the keys?
Example: I put the following in the order given:
Order Key Index
1st key1 0
2nd key2 1
3rd key3 2
If I will get the index of key2, it should return 2.
Thank you in advance.

Hi,
I will clarify a few things about how JE's storing the records to make sure we are on the same page. Also, I don't know what API you use, I assume you use the base API.
JE stores and retrieves data using key-data pairs. You store records in a Database by calling one of the put methods on a Database handle. JE automatically determines the record's proper placement in the database's internal B-Tree using whatever key and data comparison functions that are available to it. To iterate (which I think it's what you're looking for), just call getNext() until the last database record has been read. getFirst moves the cursor to the first key/data pair of the database, and returns that pair, but if If the cursor is not yet initialized, getNext moves the cursor to the first key/data pair of the database too. All cursor operations return an OperationStatus, so just read until you no longer see OperationStatus.SUCCESS. This will give you the order.
Also, instead of scanning the database in the record's sort order, you can use cursors to retrieve records based on how they are stored on disk by using the DiskOrderedCursor class.
Getting Records Using the Cursor: http://docs.oracle.com/cd/E17277_02/html/GettingStartedGuide/Positioning.html
Cursor: http://docs.oracle.com/cd/E17277_02/html/java/com/sleepycat/je/Cursor.html
DiskOrderedCursor: http://docs.oracle.com/cd/E17277_02/html/java/com/sleepycat/je/DiskOrderedCursor.html

Similar Messages

  • Primary key index not working in a select  statment

    Hi ,
    I'm doing a :
    select *
    from my_table
    where B = v1 and
    A = v2 ;
    where A and B are the primary key of the table, in that table the primary key index is there and the order of the primary key definition is A first and then B.
    While testing this statment in my database the Explain Plan shows that it is using the index ok but when
    runninng in client database it is not using it becasue of the order (i think), is this something configurable that I need to ask to my DBA ?
    The solution I found was to do the select with a hint wich fix the problem , but I'm curious about why is working in my dadabase and not in the client database
    thanks in advance .
    oracle version 11g

    This is the forum for SQL Developer (Not for general SQL/PLSQL questions). Your question would be better asked in the SQL and PL/SQL forum.
    Short answer: The execution plan used will depend on optimizer settings and table/index statistics. For example if the table has very few rows it may not bother using the index.

  • Usage of reverse key index

    Hi,
    Any body can explain the usage of reverse key index.
    Thanks and regards,

    It could be an option if you have lots of inserts simultaniously (and I mean lots not 2 a second - rather 1000'ds).
    If the index field comes like this 1000, 1001, 1002, 1003, 1004 etc etc then the very same index leaf blocks will be hit when using a "normal" index - if it is reverse, you will spread the IO load on many blocks - and might give a better performance. If reversed it will be 0001, 1001, 2001, 3001, 4001 instead (inserwise).
    BUT .... be aware when using ... between, GT og LT on those reversed indexed fields - index skip scans are not possible - so you may sacrifice performance in the selects.
    We have used it for audit records, where we had many many records being inserted from 20 simult. processes (java stuff), just reading off a jms queue and inserting. We had lots of waits - then we reversed index. And we do not have any appl. selecting the audit records.
    Mette

  • Concept about Primary Key index

    I have a partitioned table as follow:
    CREATE TABLE TEST
    (TEST_KEY NUMBER(10,0) NOT NULL
    ,FOREIGN_KEY NUMBER(10,0) NOT NULL
    ,PARAM_ID NUMBER(10,0)
    ,PARAM_VALUE VARCHAR2(256)
    PARTITION BY HASH (operation_key) PARTITIONS 15
    STORE IN (TEST_R1_TS, TEST_R2_TS, TEST_R3_TS, TEST_R4_TS, TEST_R5_TS)
    CACHE
    I also created a partitioned index for the TEST_KEY to be used as primary key index.
    CREATE INDEX TEST_PK_IDX ON PARAMETER_1(TEST_KEY) LOCAL
    STORE IN (TEST_i1_ts, TEST_i2_ts, TEST_i3_ts, TEST_i4_ts, TEST_i5_ts);
    When I try to run alter table to add primary key, I got index not exist error?
    SQL> alter table TEST add (constraint test_pk primary key (test_key) using index test_pk_idx);
    alter table parameter_1 add (constraint pa1_pk primary key (parameter_key) using index pa_pk_idx)
    ERROR at line 1:
    ORA-01418: specified index does not exist
    BUT, I could find my index in the USER_INDEXES table...
    SQL> select index_name from user_indexes where index_name like '%TEST_PK%';
    INDEX_NAME
    TEST_PK_IDX
    Why? Help is very appreciated.
    Thank you in advanced.

    check the names of the tables in the script you give ... they are different for the table and the index. When you add the constraint the table name and column name mysteriously change in the error message, so I think that you aren't showing us what actually happened.

  • Reverse key index

    hi,
    I am reading Richard Foote's notes, and he talks how reverse key indexes can stop the contention in RAC environment on an index where the values are ascending and always being entered into the right most block. But, they still wont stop the contention on the tables data block, will they? so doesnt this make disappearing the contention on the index data block futile as we're still going to have it on the tables data block?
    also, when we enter an entry into the table, is a shared exclusive table lock taken on the index too?
    thanks

    OracleGuy777 wrote:
    hi,
    I am reading Richard Foote's notes, and he talks how reverse key indexes can stop the contention in RAC environment on an index where the values are ascending and always being entered into the right most block. But, they still wont stop the contention on the tables data block, will they? so doesnt this make disappearing the contention on the index data block futile as we're still going to have it on the tables data block?
    also, when we enter an entry into the table, is a shared exclusive table lock taken on the index too?
    See Re: reverse key index and contention in RAC
    Regards
    Jonathan Lewis
    http://jonathanlewis.wordpress.com
    http://www.jlcomp.demon.co.uk
    To post code, statspack/AWR report, execution plans or trace files, start and end the section with the tag {noformat}{noformat} (lowercase, curly brackets, no spaces) so that the text appears in fixed format.
    "Science is more than a body of knowledge; it is a way of thinking"
    Carl Sagan                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • What is Foreign Key Indexes?

    We have doubt in definition of "Foreign Key Indexe",
    Please give us a clear definition.
    Thanks in advance
    Soheil

    We have doubt in definition of "Foreign Key Indexe",
    Please give us a clear definition.
    Thanks in advance
    Soheil

  • How to see wether the index is a primary key index or not

    hi,
    can anybody let me know how to get wether the index is made on the primary key (i.e primary key index)
    can we do by querying the user_constriants table.
    plz let me know..

    Maran.Viswarayar wrote:
    Vijay,
    Was that different from Anurag's reply?Yes it was. Anurag didn't include the index_name in his query.
    It is possible for the index name to be different from the constraint_name, so if you listed just the primary key constraint names you might decide that a given index was not a "primary key" index because you couldn't find a constraint with the matching name.
    Regards
    Jonathan Lewis
    http://jonathanlewis.wordpress.com
    http://www.jlcomp.demon.co.uk
    To post code, statspack/AWR report, execution plans or trace files, start and end the section with the tag {noformat}{noformat} (lowercase, curly brackets, no spaces) so that the text appears in fixed format.
    "Science is more than a body of knowledge; it is a way of thinking"
    Carl Sagan                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • Creating an unique index instaed of using primary key index

    Hi ,
    I heard in a debate sometimes it's better to create a unique index on a column and using it instaed of using primary key index in oracle.I couldn't understand what the reason propely.
    Can anyone please help me in thsi topic if it is a valid one .
    Thanks in advance

    Hi,
    They are exactly NOT identical.
    1. Unique key can have NULL values where primary keys can't.
    2. Primary key is fundamentally those keys which do not change. I mean updating a primary key is not a good idea.
    SQL> drop table test;
    Table dropped.
    SQL> create table test ( a number(2));
    Table created.
    SQL> ed
    Wrote file afiedt.buf
      1* create unique index test_idx on test(a)
    SQL> /
    Index created.
    SQL> ed
    Wrote file afiedt.buf
      1* insert into test values(NULL)
    SQL> /
    1 row created.
    SQL> drop table test;
    Table dropped.
    SQL>
    SQL> create table test ( a number(2) primary key);
    Table created.
    SQL> insert into test values(NULL);
    insert into test values(NULL)
    ERROR at line 1:
    ORA-01400: cannot insert NULL into ("HR"."TEST"."A")
    SQL>Cheers,
    Edited by: Avinash Tripathi on Nov 24, 2009 11:17 AM

  • Problem with capturing Primary Key Index

    Hi
    I am capturing certain tables and in the mean process i observed that all the indexes are getting captured except the primary key index.
    Any Suggestions on this?
    Thanx,
    Suji

    Hi,
    I was unable to reproduce this behavior on OWM 10.1.0.8. It appears that you have a SR open for this issue, so I would suggest to continue with that process.
    Regards,
    Ben

  • Drop/recreate primary key index

    Any suggestions for dropping/recreating a primary key index? The index has to be dropped/recreated and not rebuilt due to ORA-600s.
    Do I simply disable/re-enable the primary key constraint? The database is 10g.
    Edited by: nickw2 on Apr 1, 2009 5:06 PM

    ORA-600 errors are a handful, I usually check metalink or ask ORacle support for help.
    Anyways, If you want to recreate the primary key index, have you tried dropping the primary key constraint and adding it back?
    ALTER TABLE tablename
    DROP CONSTRAINT pk_name;
    ALTER TABLE tablenames
    ADD CONSTRAINT pk_name PRIMARY KEY (column_name);

  • Creating Primary Key Index

    Hi,
    Iam trying to create a Primary Index on Large table and Iam using the Parallelism to make it fast. I have used the following script to create a Primary key Index.
    CREATE UNIQUE INDEX FLX_ARCH.FUND_SEC_RESULT_STAT_ARCH_PK
    ON FLX_ARCH.FUND_SEC_RESULT_STAT_ARCH
    (FUND_SEC_RESULT_MAP_INST,RATES_RULE_ID,BASE_LOCAL_FLAG,EFFECTIVE_DATE)
    TABLESPACE FLX_PERF_I
    parallel;
    Index created.
    Elapsed: 01:43:37.37
    Index got created in 1 hour 43 minutes. But when Iam adding constarint to those columns, it is taking almost 12hours with or without parallelism.
    ALTER TABLE FLX_ARCH.FUND_SEC_RESULT_STAT_ARCH
    ADD CONSTRAINT FUND_SEC_RESULT_STAT_ARCH_PK
    PRIMARY KEY
    (FUND_SEC_RESULT_MAP_INST,RATES_RULE_ID,BASE_LOCAL_FLAG,EFFECTIVE_DATE)
    parallel
    Would you please let me know what could be the problem and how can we add the Primary constraint fast.
    Your early response is much appreciated.
    Thanks and Regards
    Suresh. D

    Would you please let me know what could be the problem and You have presented no details that indicate any problem exists.
    how can we add the Primary constraint fast. Fast is relative.
    If I asked you to make my snail fast, could you do so?
    ALTER SESSION SET SQL_TRACE=TRUE;
    ALTER TABLE FLX_ARCH.FUND_SEC_RESULT_STAT_ARCH
    ADD CONSTRAINT FUND_SEC_RESULT_STAT_ARCH_PK
    PRIMARY KEY
    (FUND_SEC_RESULT_MAP_INST,RATES_RULE_ID,BASE_LOCAL_FLAG,EFFECTIVE_DATE)
    parallel
    ALTER SESSION SET SQL_TRACE=FALSE;
    now find the trace file within ./udump folder
    tkprof <trace_file.trc> trace_results.txt explain=<username>/<password>
    By inspecting the trace file you will be able to see where time is being spent.
    With this knowledge, you may or may not be able to determine the bottleneck & therefore improve it

  • Nobody can help me? What is Foreign key indexes?

    We have doubt in definition of "Foreign Key Indexe",
    Please give us a clear definition.
    Thanks in advance
    Soheil

    We have doubt in definition of "Foreign Key Indexe",
    Please give us a clear definition.
    Thanks in advance
    Soheil

  • Issues with reverse key indexes and range scan

    I have a question. Why is it that reverse key indexes do not work in a range scan?
    Thanks

    Chris, well said in simple terms.
    Extract from metalink:
    Oracle8 provides the ability to create reverse key indexes. Reverse key indexes
    reverse the bytes of each indexed column with the exception of ROWID and still
    maintains the column order. Reverse key indexes are useful for Oracle Parallel
    Server environments.
    In an OPS environment, modifications to indexes are focused on a small
    set of leaf blocks. Reversing the keys of the index allows insertions to be
    distributed across all the leaf keys in the index. Reverse key indexes prevent
    queries from performing an index range scan since lexically adjacent keys
    are not stored next to each other. Reverse key indexes can also be used in
    situations where users insert ascending values and delete lower values from the
    table, thus helping to prevent skewed indexes.
    ===
    Good discussion at
    http://asktom.oracle.com/pls/ask/f?p=4950:8:2737861489787945222::NO::F4950_P8_DISPLAYID,F4950_P8_CRITERIA:627823669999
    http://asktom.oracle.com/pls/ask/f?p=4950:8:2737861489787945222::NO::F4950_P8_DISPLAYID,F4950_P8_CRITERIA:6163160472530
    Jaffar
    Message was edited by:
    The Human Fly

  • WEP with key index 3

    In my organization the WIFI is set on key index 3. Is there anyway to connect the IPAD as I do not find any possibility to set the key index 3 on the WIFI settings?
    thanks

    The following article says:
    Check the wireless security option of your Wi-Fi router:
    If you are using WEP security and have multiple WEP keys on your Wi-Fi router, try configuring your Wi-Fi router to use only a single WEP key in key index 1.
    Consider using WPA or WPA2 instead. WPA and WPA2 encryption protocols are newer, more effective security options for wireless networks than the older WEP protocol.
    http://support.apple.com/kb/TS3237
    Thus, it appears you may only be able to use key index 1

  • WEP Key index other that "1"

    Hi All:
    I brought a new macbook, i have switch from Dell to MAC, im pretty happy so far, except for the following...
    You can only setup Airport on to send and connect to wireless networks on WEP Key index 1, i have several customers that we i came into their locations, the main Wireless key index in other than 1. They use 2, 3 or 4. Unfortunatelly it seems to me and to rest of people i found on the new, apple only supports 1.
    This as no sense to me, and i think there needs to be a workaround to fix this.
    Can anyone tell me what we can do in order to connect to wireless networks that use other that WEP #1???
    Thanks and all the best!
    Federico

    Ok... I have a wifi here at home.... and probably in the modem settings there are 4 keys Just try one and put it on the password asked. And you shall get internet connection right away... Hope i helped you!!!

Maybe you are looking for

  • [Solved] System completely broken after update

    Today while updating my system as usual something went south terribly fast Here's the pacman log of the update [2009-07-09 12:14] synchronizing package lists [2009-07-09 12:14] starting full system upgrade [2009-07-09 12:18] upgraded kernel-headers (

  • Can't load VM shared library on dev_bootstrap

    Hi, I try to install a J2EE on a Redhat server with sapdb x86_64, and on the start phase the bootstrap crash with this error: [Thr 1086335328] JLaunchIStartFunc: Thread 1086335328 started as Java VM thread. [Thr 1086335328] *** ERROR => DlLoadLib: dl

  • Using Stored Procedure in JSP

    Hi Everybody, I hope some one can help me out. I want to call a PL/SQL Procedure in my JSP Page. Can anybody please tell me how this can be done. Thanks

  • How to save music onto computer

    I am soon going to send in my iTouch to Apple, and most of my music is from a different computer/iTunes library. I dont want to have to reload all of my music, so how can I save my music to my computer???

  • Using a script to call named destinations causes blank pages

    My first post in the Adobe forums. I realize that this may not be exactly the right location for this question, but this forum seemed to be the closest to what I need. We are trying to use the following script to call named destinations in an Acrobat