Re: HOW speed up slow script ? (3500 lines/ 130 kb)

From: Date: Mon, 05 Jun 2000 19:11:44 +0000
Subject: Re: HOW speed up slow script ? (3500 lines/ 130 kb)
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-1085@lists.php.net to get a copy of this message
on 6/5/00 11:54 AM, helmut ott at haott@freenet.de wrote: > I have a one in all script (php/mysql/unix) for list and detail views and add, > edit, delete functions. alltogether 3500 lines of code / 130 KB. A record has > 140 fileds, with right now only 100 records in the database. The query takes > about 15 seconds for a "list all records"-query. And thats pretty slow. But I > want to put at least 30000. > > WHAT should I do to speed it up (e.g. built indexes, split up script ......) ? I would take a good hard look at how you are building your database. I can't really think of many applications that would need a 140 column database. Are you finding that you are putting a lot of redundant data into the thing? If so you may want to take a more Relative Database approach. i.e. for an online store, we have the customer information in one table, the actual shopping cart line items in another, and then have a another table that pulls from both to build the correct information. ie. table_cust cust_id cust_name cust_address 1 Joe Blow 1234 Anywhere St. table_orders order_id cust_id 1 1 table_orderlines line_id order_id item_name item_price 1 1 Redhat Linux 6.2 69.99 SELECT cust_name, cust_address FROM table_orders O, table_cust C WHERE (O.cust_id = C.cust_id) AND (O.order_id = 1); SELECT item_name FROM table_orderlines OL WHERE (OL.order_id = 1); Will pull the customer name on the first select, and the second will print all the items in their shopping cart. The orders table keeps track of what order goes to what customer, etc. If you can do a describe table and post it, we may be able to come up with some better ways of organizing the data, by using joins, etc. Also Joe Celko's SQL for smarties is a pretty good book and goes a long way to help optimize SQL queires and structures of database for performance, ease of use, etc. -k

« previous php.general (#1085) next »