Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 674447
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T00:42:28+00:00 2026-05-14T00:42:28+00:00

SELECT MAX(verification_id) FROM VERIFICATION_TABLE WHERE head = 687422 AND mbr = 23102 AND RTRIM(LTRIM(lname))

  • 0
SELECT MAX(verification_id)
  FROM VERIFICATION_TABLE
 WHERE head = 687422
   AND mbr = 23102
   AND RTRIM(LTRIM(lname)) = '.iq bzw'
   AND  TO_CHAR(dob,'MM/DD/YYYY')= '08/10/2004'
   AND system_code = 'M';

This query is taking 153 seconds to run. there are millions of rows in VERIFICATION_TABLE.

I think query is taking long because of the functions in where clause. However, I need to do ltrim rtrim on the columns and also date has to be matched in MM/DD/YYYY format. How can I optimize this query?

Explain plan:

SELECT STATEMENT, GOAL = ALL_ROWS           80604   1   59
 SORT AGGREGATE                                   1   59
  TABLE ACCESS FULL P181    VERIFICATION_TABLE  80604   1   59

Primary key:

VRFTN_PK    Primary VERIFICATION_ID 

Indexes:

N_VRFTN_IDX2    head, mbr, dob, lname, verification_id
N_VRFTN_IDX3    last_update_date
N_VRFTN_IDX4    mbr, lname, dob, verification_id
N_VRFTN_IDX4    verification_id

Though, in the explain plan I dont see indexes/primary key being used. is that the problem?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T00:42:28+00:00Added an answer on May 14, 2026 at 12:42 am

    Try this:

    SELECT MAX(verification_id)
      FROM VERIFICATION_TABLE
     WHERE head = 687422
       AND mbr = 23102
       AND TRIM(lname) = '.iq bzw'
       AND TRUNCATE(dob) = TO_DATE('08/10/2004')
       AND system_code = 'M';
    

    Remove that TRUNCATE() if dob doesn’t have time on it already, from the looks of it (Date of Birth?) it may not. Past that, you need some indexing work. If you’re querying that much in this style, I’d index mbr and head in a 2 column index, if you said what the columns mean it’d help determine the best indexing here.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

For the query: SELECT MAX(LOG_CREATION_DATE),COL_A, COL_B FROM IMPORT_LOG GROUP BY TO_CHAR(LOG_CREATION_DATE, 'MM-DD-YYYY'), COL_A, COL_B
SELECT MAX(some_field) FROM table_A GROUP BY another_field This only gets the max value of
SELECT MAX(crash_year) AS crash_year, COUNT(crash_year) AS COUNT FROM nyccrash GROUP BY crash_year ORDER BY
string queryStr = select max(patient_history_date_bio) + as med_date, medication_name from biological where + (patient_id
The scenario is this: select max date from some table, when the target table
When I attempt to do something like SELECT Max(ObjectId) FROM Objects; I see that
myTable UNID 9 10 UNID is a VARCHAR2 select max(UNID) from myTable returns the
SELECT ISNULL(MAX(ColumnName) + 1, 1) AS ColumnName FROM TableName How to write this query
SELECT * FROM tbl WHERE version = (SELECT MAX(version) FROM tbl WHERE t2.entityId =
Is using SELECT Max(ID) FROM table safer than using SELECT last_insert_id(), where they run

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.