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 7706735
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T00:11:21+00:00 2026-06-01T00:11:21+00:00

Suppose, I have a float column and a a b-tree index and a million

  • 0

Suppose, I have a float column and a a b-tree index and a million rows:

CREATE TABLE test (
     val FLOAT,
     KEY (val)
);

INSERT INTO test VALUES (random(-1000, 1000)), (random(-1000, 1000)), ...

(1M rows)

Now, if I want to make a query like

SELECT * FROM test WHERE abs(val) > param

or

SELECT * FROM test WHERE int(val) % 2; /* odd integer numbers only */

What databases can optimize this to use the index on val, so that I don’t have to use an index on the expression I check, or reverse expression myself?

  • 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-06-01T00:11:22+00:00Added an answer on June 1, 2026 at 12:11 am

    I don’t think any DBMS can use a “plain” index on val if you use that column in a function or expression.

    The main reason is that the result of applying the function could make the index lookup very expensive at best (basically creating an index based on the expression “on the fly”) or plain wrong in the worst case in case the index lookup for the “plain” value returns a completely different row than the index lookup on the result of the expression (which is very likely to happen).

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

Sidebar

Related Questions

Suppose I have a table called Companies that has a DepartmentID column. There's also
Suppose I have a table of customers: CREATE TABLE customers ( customer_number INTEGER, customer_name
Let us suppose i have these three methods defined: int F1(int, int); int F1(float,
Suppose we have a table A: itemid mark 1 5 2 3 and table
Suppose I have BaseClass with public methods A and B, and I create DerivedClass
Suppose I have variables for positions like const float latitude = 51.+11./60.+33.0461/3600.; const float
Suppose I have the following table: Table: Score field: ID: uniqueidentifier field: Departmentid: int
I have a column A in a table called T . The column is
Suppose I have a very small float a (for instance a=0.5 ) that enters
Suppose I have some code such as: float a, b = ...; // both

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.