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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T11:48:28+00:00 2026-06-08T11:48:28+00:00

I am trying to improve an old system (written ages ago) where every mysql

  • 0

I am trying to improve an old system (written ages ago) where every mysql queries are glued from string. So example of that query looks like

"SELECT * FROM User WHERE id > '3'"

Id column is of course bigint and PK.

What does mysql do with ‘3’ in query where id should be a int value? I assume it is treated as a string (due to ”) so this value is casted into int during analyze/optimize process by mysql. Am I right?

//UPDATE
I probably asked wrong way. There are two way to handle it.

  1. (Fast) Mysql automatically detects that id should be int and rewrite/cast a query to

     SELECT * FROM User WHERE id > 3
    

    before send it to DB engine

  2. (Unbelievable) Mysql does

    SELECT * FROM
    

    then in loop apply condition WHERE id > ‘3’ and cast it for EVERY row

I just want to be sure that second option is impossible.

  • 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-08T11:48:31+00:00Added an answer on June 8, 2026 at 11:48 am

    MySQL will always cast the string to a number for comparing, which in this case this is the right thing to do (it will use the index on the column to find the values).
    If your column is a string and you compare it to an integer constant MySQL will cast the column to an integer and not use the index.

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

Sidebar

Related Questions

I'm trying to improve on some code that was written a while back. the
I'm building an online shop & trying to improve performance by minimising MYSQL queries.
I'm trying to rebuild an old metronome application that was originally written using MFC
I'm trying to improve the performance of a website written in classic ASP. It
I am trying do string formatting with a unicode variable. For example: >>> x
I'm trying to improve the readibility of a published date being pulling in from
I am trying to improve my C++ by creating a program that will take
trying to convert all my old mysql_* operations into new and, from what i've
I am trying improve the fault tolerance in a JSP-page that is updated on
I trying to improve a textbox that filters a gridview, by implementing an enhanced

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.