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

  • Home
  • SEARCH
  • 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 9227239
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T05:01:22+00:00 2026-06-18T05:01:22+00:00

To interpret a normal PHP file (without using MySQL) it takes about 0.01 Milliseconds.

  • 0

To interpret a normal PHP file (without using MySQL) it takes about 0.01 Milliseconds. But if you add mysql_connect() or mysqli_connect() or any other function to connect to a DB it takes much more time to interpret it. (usually about 1.05 Miliseconds).

I’ve tested so many times, the problem occurs when connecting to the database. No matter how many queries you run, they’re super-fast. But Why connecting to a database is slower than querying from it.

What’s the problem here ? What’s the fastest way to connect to MySQL ?

I am using XAMP with Apache & MySQL on Windows 7

  • 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-18T05:01:24+00:00Added an answer on June 18, 2026 at 5:01 am

    When you connect to MySQL you are opening a socket connection. This is routed through the network layer of your operating system, and there is a handshake to perform for every connection where the client (your code) passes the username and password, and the database engine has to validate those credentials. Then the client opens a connection to a specific database.

    This is known as the “overhead” of opening a database connection.

    The best solutions are, (a) don’t worry about a 1ms delay in your code, there are probably other ways you can get that performance benefit back, and/or the user won’t even notice that 1ms; or (b) if you really really must have it micro-optimised, then you only connect once per page, or not at all if you don’t need the connection on that particular page.

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

Sidebar

Related Questions

I'm using php with xmlreader. I'm trying to read an file with an include
Is there any way to interpret normal mathematical notation into Reverse Polish Notation(RPN)..? eg
Is there any way to interpret Reverse Polish Notation into normal mathematical notation when
Is it possible to interpret every coming packets using sharppcap?
I need to read a PNG file and interpret all the information stored in
I'm trying to find a xml-interpret function (like the simplexml_load_string) in Python, but with
I am templatizing my php.ini using PHP. I have a script to set up
Every time I request a .php file I get the 500 error code. I
I need to read and interpret a binary file containing a TIFF image. I
I'm using Codeigniter not for so long but I've some charset problems.. I'm asking

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.