Optimizing Query That Runs Slowly On Linux
I was wondering if anyone has any insight into why the query I have posted below runs exceedingly slow on my Linux server. I am using Php with a MySQL database. On both my development computers the query runs briskly. They are however both Windows boxes, one running Windows XP and the other running Windows 2000 Professional. Here is the culprit.....
View Complete Forum Thread with Replies
Related Forum Messages:
Bad Query Runs With No Error!
there must be some weird setting on the mysql database i am using for this latest project. the following query runs without throwing an error: SELECT start_time, last_access_time, user_ip session_data FROM demo_sessions WHERE id='b31fd40c7e9135f2b52e4f17c23fc3c54da137b8' notice there is no comma between user_ip and session_data what's the story here? seems like a real security risk to me because my server won't log bad requests.
View Replies !
Analyzing And Maybe Optimizing A Query.
I'm building a forum with a mysql backend. The forum has the following structure: - category |--> forum |--> thread |--> replies Once the user has defined a forum (id), i first need to get the name of the forum, the category it's in, and how many threads there are in the current forum. I use the query below, which works fine, *but* ( shame, shame ) i don't really understand how/why it works. I tried to read the mysql manual and everything, but since my native language isn't english, and there are quite a lot of technical related words in it, it doesn't really make sence to me. I built this query myself, with a lot of trial & error work ... Again, the query works fine, but i don't understand how, and i don't know wether or not it can be optimized ... (especially the GROUP BY part i seize to understand)
View Replies !
Query Runs In Mysql But Returns Error 1064
The same query runs in mysql and in Zend interface but not runs when using inside php script. I am receiving the error: "1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'str_qry_Insert' at line 1" INSERT INTO fnd_script_type (type_name) VALUES ('test1') I already have tried it with as: INSERT INTO `fnd_script_type` (`type_name`) VALUES (`test1`) INSERT INTO fnd_script_type (`type_name`) VALUES (`test1`) INSERT INTO fnd_script_type (type_name) VALUES (`test1`) what am i doing wrong ?
View Replies !
Query Runs Multiple Times Under Heavy Server Load.
I have been having an issue with some MYSQL queries running multiple times when the server is under a heavy load. Example, if I do an 'update Table1 set item1 = 0 where 1 = 1' This runs fine under normal conditions, but will repeat itself multiple times when the server is under load. Is this just an optimization or server resource issue. If so, I would assume the query would just timeout and not run at all instead of running a few times.
View Replies !
PHP Execution On Fast CGI Running Slowly
I recently started working on a Web application that has been written in PHP. It is using the single threaded version of PHP. It runs very slowly when it has a large user base. I have spent some time trying to debug it and speed it up, and have run into a roadblock. The server code executes in 4-5 seconds, and the payload to the client is relatively small. The process php-cgi.exe *32 (CGI /Fast CGI), however, is using lots of memory, and although the header is returned to the client fairly quickly, this process runs for a long time (sometimes for more than 10 minutes). Based on debug info, all of the pages have finished processing. I have not been able to determine the reason for the slowness. My guess is that php is running through the memory cleanup algorithms, and that they are inneficient for large amounts of data. Has anyone experienced anything like this, or have a workaround? I am currently working to solve the problem from two angles. The first is to try and see if there is a way to help clean memory, but so far I have been unsuccessful. The second is to reduce the data in memory (used by php-cgi.exe) This has also been unsuccessful. There is a function that seems to be using an extraordinary amount of memory to load only a few strings into an array. Code:
View Replies !
Queries Causing Page To Load Slowly
I'm currently having trouble getting a looped query to display the results in as quick a time as possible. At the moment the query takes far to long...and that's if it executes at all. At the moment i have around 3000 movie titles in the DB. Can anyone suggest a way of populating the select box in a relatively quick manner? Here is the code: PHP Code:
View Replies !
Optimizing
There has got to be a better way to do this than the way I bushed together without total knowledge of what I am doing. So I attached the actual file so you can see all the 33-ish k of data on 1 page just in text alone :eek:. What can I do to call the same info in less data usage? The main thing that is taking up room is this repeated section: Code:
View Replies !
User Runs PHP
I have an app that uses PDFLib to read some images off the file system (Red Hat linux) and puts them into a PDF. I have permissions set on the directory to be readable by the owner and the group, 'images'. I made apache a member of the group 'images' but get a permission denied error when trying to read an image from the images directory. Is there some other user that owns the PHP app. Env. PHP 5.03 Red Hat ES4 Apache 2.02
View Replies !
Optimizing A Mysql_list_tables ()
im trying to list each table in a db, then do a query on each table returned to display the results of each query on each table there are 25 tables, and i get a minimum 500 hits to this code per day: PHP Code:
View Replies !
Optimizing A PHP Script
I have a small PHP script that creates an XML doc on-the-fly for an AJAX application. Right now the page that we've got is just using a meta refresh to fetch the new data from the server, but that's so 1999! I'm incorporating AJAX to fetch the new page data now so I've got a quick question. Is it faster to just use echo() to echo out the whole page with my variables like this: <?php echo "<?xml version="1.0"?>"; echo "<root>"; echo " <element_1>$element_1</element_1>"; echo " <element_2>$element_2</element_2>"; etc. etc...? Or is it faster to just output the XML directly and insert the data in code blocks like so: ?> <element_1><?=$element_1 ?></element_1> <element_2><?=$element_2 ?></element_2> etc. etc...? I'm just wondering which is faster. Our site is already seeing a lot more traffic than we anticipated so I'd like to optimize the PHP as much as possible. Even if one only saves a few milliseconds over the other, it's a big savings over a long day of hundreds of thousands of page hits.
View Replies !
Optimizing SQL Queries
I currently have a DB with several rows of submitted items in it. There are several items per user, but I am only interested in getting the first 3 for each user. The script from the previous coder calls each query seperately, but this is hard to maintain and I was hoping I could put this all in a single SQL statement instead. Right now the script queries for 3 rows from user #1 and stores in array, then calls for next 3 from user #2 and stores in array etc etc. I'm looking for a SQL statement like so: $sql = "SELECT first 3 items for each UNIQUE user ORDER BY date_added ASC"; (yes, sql is wrong, its just an example to show what I want!) I really hope this is possible, it would really cut down a lot of redundant code we have now. I did look at MySQL site and PHP site, but could not find anything that looked like it would do the trick.
View Replies !
Optimizing MySQL
I wrote a php+MySQL-based reservations system for a local restaurant. MySQL is running on AMD Athlon 3000+ 2GHz with 1.5Gb of RAM. The system is accessed through Intranet by 4-5 machines. The main reservations table weighs only 40k with around 150 entries, but I'm getting weird lags in the middle of the pages - half of the table loads ... LAG! ... then the other half loads. This is especially annoying considering the table will contain around 3,000 - 5,000 entries per year, entries older than 2 years will be removed. The lags persist on MySQL server (locally), so it's not a network issue. The lags are espeically bad when I do a query like "SELECT name, phone, notes FROM reservations WHERE date > %today%" - it literally takes 5-6 seconds to pull one row. I don't use "SELECT ALL" queries, my tables are optimized, etc.
View Replies !
Optimizing A Function
This is a function that I use quite often. I pass in my SQL string and return the results as an array. I can make (eventually I would like to make a class, but I am still new). function table_array ($sql_string) { $result = mysql_query($sql_string) or die("dead"); $num_rows = mysql_num_rows($result); $num_fields = mysql_num_fields($result); $j = 0; $x = 1; while ($row = mysql_fetch_array($result)) { for($j = 0;$j < $num_fields;$j++) { $name = mysql_field_name($result, $j); $arr[$x][$name] = $row[$name]; } $x++; } return array('arr' => $arr, 'rows' => $num_rows, 'fields' => $num_fields); }
View Replies !
Optimizing Code
I spent time optimizing my code and adding a little smart functionality here and there, based on needs and simplicity. In this context, I was wondering about something. I have a growing include.inc file that holds all my functions in it. Thinking speed, I was thinking that it might be a bit faster to split that include.inc file up into the different functions and then only include_once those that actually are needed by the different pages. Code:
View Replies !
Optimizing Recursion
I have a recursive function that builds a directory tree. Each function call looks at a record in the database, finds all the child nodes, then recurses the function for each child. So basically it starts at the root and digs down on each branch of the tree until it finds a leaf. It's a pretty standard way of doing depth-first "digging" for a hierarchical tree. Code:
View Replies !
PHP Only Runs From Command Line
I know very little about PHP, but I was just curious to know why exactly would some PHP code run fine from the command line but not from the browser? I'm just curious. I was working with someone else's PHP code that supposedly created MySQL tables in a database and for some reason it just wouldn't create the tables at all (no specific error message). Someone suggested I run from the command line and when I did, it worked...
View Replies !
Optimizing A PHP MySQL Script
I need to do a conversion on a DB. The dates are stored on a way that MySQL cannot understand, so I have to take all of them and convert them to the yyyymmdd format. The problem is that the DB is HUGE. I mean, at this moment it has more than 86000 registers. The script I am using right now says to me that it will take 61 days on completing the task - most unacceptable. With a sample DB of 800 registers, it would take only 20 secs on doing the task, but the queries on the complete database are slowing to the infinite all the process.
View Replies !
Optimizing Code For Less Queries?
The way I currently have my code written is running 21 queries I am looking for help on optimizing the code. First question is would running one query and then using PHP to run through a array be better than running the 21 queries? (faster less server intensive?) Code:
View Replies !
Optimizing Memory Usage
I issue this command: mysqld_safe --key_buffer_size=64M --table_cache=256 --sort_buffer_size=4M --read_buffer_size=1M & this is the response: [root /root]# A mysqld process already exists How can i execute this command succesfully?
View Replies !
Optimizing Mysql Queries
have a feeling that this isn't very optimal. Is there a way where you can put all these mysql queries into one or more fewer than this? This way works great, though a bit too much queries. $querytotal = mysql_query("SELECT id FROM $db WHERE date_pub='$week' AND visible=Ɔ'"); .......
View Replies !
A Question About Overhead And Optimizing
I have oner large table and from time to time it' s overheaded. To fix it I run optimize command. But it doesn't help a lot - in some 5 minutes the table is overheaded again. Then I noticed that after some time it's not overheaded anymore (I didn't run optimize command). My question is - what is the reason to optimize tables if overheaded tables after some time are not overheaded anymore even without optimizing?
View Replies !
Optimizing Multiple INSERTs
I have a set of text fields (named "link1" through "link5") and a kludgy script that writes each field to a row if the field is not empty: if (empty($link1)) { $query = "INSERT INTO table (field) VALUES ('$var1')"; $result = mysql_query($query); } if (empty($link2)) { $query = "INSERT INTO table (field) VALUES ('$var2')"; $result = mysql_query($query); }
View Replies !
Why Script Runs Differently With CRON?
I am running a PHP Script that downloads my RSS News (and the accompanying Thumbnail images)from the Web. When I execute it from CMD line, no problem. The News and Images are downloaded, great! When I begin to update via CRON, no images are downloaded/written to disk.--I don't have this problem when it's RUN from a shared hosting account, it's only on my home Linux Box.
View Replies !
Bug 23891 MySQL Runs Out Of Connections
http://bugs.php.net/bug.php?id=23891 According to this report, what the person was asking isn't a bug, it's a feature (rimshot). I'm running into this problem almost exactly, and really don't understand what the answer is. The support person snidely suggests reading the manual, which is always great advice, but in this case really doesn't help out. Could someone explain what "If you use mysql_select_db() or slightly different connection string you can have more open connections then you have process." means? If I don't use mysql_select_db, then what do I use?
View Replies !
EXEC() Runs Process In Background
Exec, shell_exec, system, popen functions all run the process in the background. how can i get it to run the process normally. my code looks like this: <? exec("batch_file.bat"); ?> am i doing anything wrong?
View Replies !
Close Window After Script Runs
When a user clicks on a link in their email, I have a browser window that opens in the background and runs a script confirming their desire to be added to our email directory. I basically want this window to open, run and then close without the user having to deal with it. Is there a way in PHP to close the window after the script finishes running in it? Or should I revert to JavaScript? I want the script to be mobile so I've sort of ruled out processing it server side. TIA.
View Replies !
How Often Does Garbage Collector Runs In Sessions?
Does anybody knows how often the session garbage collector checks for expired session to delete them? is it possible to modify this timeframe? is it possible to call this function manually? I am storing my sessions in a mysql database and i am using a session expiration of 5 seconds (just for testing), but after the session is expired the session record in the db table still exists. and it looks the sessions aren't expiring either because if you still have the session cookie you can keep up with the session. Code:
View Replies !
Email Form Which Runs From An Iframe
I have set up an email form which runs from an iframe. The only problem is that when the script redirects the user to the success or error pages, these pages open within the iframe. Is there a way to specify the target window as 'parent'? Someone said that this could not be done via the php script and would have to be done with javascript in the html form itself.
View Replies !
Optimizing Mysql For Picture Uploads
I'm just wondering how I should structure mysql for my members to upload larger files such as pictures or other types of media files. In other words, if my members use pictures to upload should the pictures be stored in one folder or should a folder be created for each member. If I was to create a folder for each member (if that would be the most efficient manner) then how would I get linux or freebsd to create the folder dynamically? If I was to implement the former method (i.e. store all the members pictures in one folder) then would that not become really slow if there are a large number of members trying to access the folder?
View Replies !
Optimizing A String Manipulation Script.
I'm not really accustomed to string manipulation and so I was wondering if any of you could be any help i speeding up this script intended to change the format of some saved log information into a CSV file while removing duplicate records. The main problem is that the script currently takes about 20 seconds to execute, and were it to take much longer it would time out. Below is the script itself, and then some example lines from the log file it processes:
View Replies !
Optimizing Dynamic Php Code (entire Site)
my web site seems to load rather slow because it accesses the db several times and there is a lot of code (because of features). i was wondering how i could optimize/cache this so that the query is only executed once (until i modify the actual code). any ideas?
View Replies !
Header Function Runs Before Update To Database Is Made
I have been having some problems with a part of my login script. This is the two lines of script I am having problems with: mysql_query("UPDATE " . $userName. " SET login = '$loginIN' WHERE pass = '$password' AND course = '$courseID'"); header( 'url=http://www.somewebsite.com/logged_IN.htm' ); The problem is that when this php script is executed the second line executes before the first and an update to the database is not made. I also tried the script without the second line and the first works then.
View Replies !
Optimizing MySQL To Make Site Load Quicker
I recently coded a site that is based mainly off of mysql. I currently query the database 4 times in two for() loops I'm not sure how to change it, because I see no other way. I can't put the queries outside of the loops because in the loop it queries something different every time. I want some help optimizing it! However, I don't want to post all my code here, because it's basically the main part of my site, and I don't want others copying me.
View Replies !
Working With Dates - Runs And Queries The Database To Produce A List Of Information
I have a script that runs and queries the database to produce a list of information, based on a date range. This is to fllow up on a script that is automatically run each Sunday night. What I want to try and acheive is, for example, if someone manually runs this report on a Tuesday the script will assume that it is run on the Sunday night, to make sure the results are exactly the same as the emails that have gone out. PHP Code:
View Replies !
"Please Wait" Page While Php Runs Mysql Queries
Does anyone have any idea what I should google to create a "splash page" that tells the user to wait while a few mysql quieries are run through the php page? It takes anywhere from 5 to 20 seconds, and I don't need a progress meter, just a splash page so they do not go anywhere and the user doesn't think there is a problem with their browser or network connection.
View Replies !
Php Runs Slower And Slower
I have phpmysql runs to fetch information from a database.One proble I have is that as the number of rows it fetched, it ran slower and slower. Sometimes it even says the query is wrong, although it is not.
View Replies !
Use Query Result Field As Query Key For New Query..
$query  = "SELECT ProjID, UserID, ProjDesc, file, OrigProj, OrigUser, ProjDate FROM projects"; $result = mysql_query($query); I would like to take the field 'UserID', and utilise it for a Query statement to my users table in my database, to read and fill in information to my table, which looks like this: PHP Code:
View Replies !
Linux -PHP
i would like to install linux on my PC , however i am a little unsure of which version to choose , with all the ones out there , i want to use it for Perl,PHP,MYsql,Apache Also what is diffrence between FreeBSD and Linux if any ?
View Replies !
PHP Is The VB Of Linux
I'm talking to get this off my chest. I guess I'm talking to the newbies out there wondering if they want to remain on ASP.NET, C#, JSP, or whatever, or whether they want to do their next project in PHP. Okay. I moved from Microsoft Windows 2000 and Visual Basic and ASP to Linux and JSP. I plan to stay on Linux now. Let's just say that I did it, but JSP was aggravating. I had to type 10 times more code than I felt I had to, and the data types always got in my way. Often I would have to write some code, fix it, recompile again, then test, find a bug, go back, etc. -- the compilation step was aggravating and slowed things down a great deal. I kept wanting a VB for Linux. Then, I started working with PHP and MySQL because I felt it had finally matured. To my surprise, besides the {} and ;, PHP pretty much is the VB of Linux thanks to the raw speed of the Zend PHP4 engine, if not the PHP5 one around the corner. With PHP, I don't have to worry about data types, mess with the slow compilation step, have the pain of adding the JDBC connector to JSP, and I can write 10 times less code and still have pretty fast pages. And, since you can now compile PHP, you can run even faster than JSP if you need to do so. To top things off, PHP is soon going to have a cross-platform GTK+ windowing engine so that one can make standalone apps or client/server form apps. When I say VB and ASP, I didn't mean VB.NET. I took a class in VB.NET and had to write code in C# and ASP.NET. Microsoft made some things easier, and some things were ten times harder. I found the XML/XSLT library sucked and was incomplete compared to the old one. Plus, I realized I was writing for an unstable, unsecure, proprietary platform that is doing nothing but get more and more complex. I thought, if Windows is going in the direction of complexity and lock-in, and Linux and Java is doing a 180 on that, and things have matured with Linux and Java, why don't I just make the move, wholesale, to Linux? And it was done. At first I liked JSP just to be free from Microsoft, but I'm very glad I finally moved to PHP, where I plan to stay. RedHat 9 made Apache, PHP, and MySQL a snap to install -- using nothing but 6 checkboxes on the Add/Remove Programs and inserting the disks. Right now, the buzz is all about MySQL and LAMP, but with PostgreSQL starting to grow up, and because of MySQL's licensing changes, we all might be moving to LAPP with PostgreSQL, remaining open source. So, anyway, I'm thinking about writing a work order management system / CRM as either a PHP web app, or a PHP/MySQL (or PostgreSQL) appliance. I plan to make an open source version, and then a customized version that I can sell for cash. The appliance would be a rackmount 2 drive hardware mirror, AMD proc., with tape drive. Yes, it would be built on Linux. You would manage the appliance with a web browser and it would do nothing but feed it the daily tapes, keep it in a cool, dust-free environment, and give it a nice UPS. So, newbies, if you are looking for the "VB" in Linux, look no further than PHP.
View Replies !
PHP As CGI Does NOT Under Linux??
I created simply test file (<?php phpinfo(); ?>) and tried to install php as CGI under my RedHat 9. PHP 4.3.8 was compiled from source tarball. mod_php under Apache 1 and 2 works, only CGI does not work! :( Apache logs contains "Premature end of script headers". Web browser can see "Internal message" :( I checked two, different instalation in httpd.conf. None of them works correctly and I do not know why. First approach: ScriptAlias /php4/ "/usr/local/php4/bin" AddType application/x-httpd-php .php Action application/x-httpd-php "/php4/php" Second approach: ScriptAlias /php4/ "/usr/local/php4/bin/" AddHandler php-script .php Action php-script "/php4/php"
View Replies !
Php Run In Linux
if i am provided a system to do with php mysql.. but it required for the linux OS.. is my php code exactly the same as what i do in window xp?
View Replies !
|