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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T23:32:02+00:00 2026-05-21T23:32:02+00:00

Wondering what would be quicker for a mysql open, select, and a generic output

  • 0

Wondering what would be quicker for a mysql open, select, and a generic output of the data:

A) C++ code compiled, an being called through exec() (or something equivalent)

or

B) Straight PHP Code.

Given that all code is equally coded in both C++ and PHP.

Did a test:
this is the C++

Document Length:        100000 bytes
Concurrency Level:      2
Time taken for tests:   0.139 seconds
Complete requests:      10
Failed requests:        0
Write errors:           0
Total transferred:      1001550 bytes
HTML transferred:       1000000 bytes
Requests per second:    71.76 [#/sec] (mean)
Time per request:       27.872 [ms] (mean)
Time per request:       13.936 [ms] (mean, across all concurrent requests)
Transfer rate:          7018.29 [Kbytes/sec] received

This is the PHP:

Concurrency Level:      2
Time taken for tests:   4.115 seconds
Complete requests:      10
Failed requests:        0
Write errors:           0
Total transferred:      1001550 bytes
HTML transferred:       1000000 bytes
Requests per second:    2.43 [#/sec] (mean)
Time per request:       822.924 [ms] (mean)
Time per request:       411.462 [ms] (mean, across all concurrent requests)
Transfer rate:          237.71 [Kbytes/sec] received

Here are the programs (I did not include MySql code -just wanted to see if the stack creation was quicker with basic code).

C++

#include <iostream>
#include <sstream>
#include <string>

using namespace std;

int main()
{
    stringstream x;
    //string x;
    for (int i = 0; i < 100000; ++i)
    {
        x << "X";
    }

    cout << x.str();
    return 0;
}

Here is the PHP:

for ($i=0; $i<100000; ++$i)
{
    $x = $x . "X";
}

echo $x;

Don’t know if its a fair test using stringsteam… thoughts? My thought is, C++ is going to be faster regardless of the new stack instance, and mysql connections.

Edit:

Tested with this:

#include <iostream>
#include <sstream>
#include <string>

using namespace std;

int main()
{
    //stringstream x;
    string x;
    for (int i = 0; i < 100000; ++i)
    {
        x = x + "X";
    }

    cout << x;
    return 0;
}

and, still quicker!

Concurrency Level:      2
Time taken for tests:   0.115 seconds
Complete requests:      10
Failed requests:        0
Write errors:           0
Total transferred:      1740 bytes
HTML transferred:       0 bytes
Requests per second:    86.98 [#/sec] (mean)
Time per request:       22.994 [ms] (mean)
Time per request:       11.497 [ms] (mean, across all concurrent requests)
Transfer rate:          14.78 [Kbytes/sec] received

Edit:

Here is the php program that calls the C++ file

<?php

echo exec("./test");
  • 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-21T23:32:02+00:00Added an answer on May 21, 2026 at 11:32 pm

    So let’s see. Let’s fire up a shell, pass it some arguments, which fires up another app, which loads a series of .so libraries, and THEN connects to mysql, does stuff, then has to return a potentially huge lump of output via printf() or equivalent, which then has to be fed back to PHP, parsed as plain text, torn apart, and then turned into some kind of coherent structure.

    And this would be faster than doing the query within MySQL and getting the data directly into a PHP structure?

    Maybe you should test it…

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

Sidebar

Related Questions

I provide a web service to my organisation. i was wondering would anyone recommeding
I was wondering what would be the best strategy to implement a badges system
I'm wondering what would be the best prectice regarding mainataining connections to the database
As a follow-up to another question , I was wondering what would be the
Just wondering how you would go about implementing something similar to stackoverflow'd related questions.
I'm wondering how you would go about designing a good permgen space string in
I was wondering if it would be possible to retrieve the complete list of
I was wondering if someone would be able to help me write a CQL
I am wondering how you would approach this problem I have two Taxrates that
I was wondering if InnoDB would be the best way to format the table?

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.