addressalign-toparrow-leftarrow-rightbackbellblockcalendarcameraccwcheckchevron-downchevron-leftchevron-rightchevron-small-downchevron-small-leftchevron-small-rightchevron-small-upchevron-upcircle-with-checkcircle-with-crosscircle-with-pluscrossdots-three-verticaleditemptyheartexporteye-with-lineeyefacebookfolderfullheartglobegmailgooglegroupshelp-with-circleimageimagesinstagramlinklocation-pinm-swarmSearchmailmessagesminusmoremuplabelShape 3 + Rectangle 1ShapeoutlookpersonJoin Group on CardStartprice-ribbonShapeShapeShapeShapeImported LayersImported LayersImported Layersshieldstartickettrashtriangle-downtriangle-uptwitteruserwarningyahoo

Re: [php-49] sql error

From: Mike B.
Sent on: Monday, February 18, 2013 4:17 PM
The performance difference will depend on the access path to the data that the RDBMS chooses. It can be no difference (if "*" turns out to mean columns that are covered by the chosen index) or it can be all the difference in the world. "*" might mean wide columns (actually LOB or not) that are inefficient to retrieve and extremely wasteful if not needed. In a join, it will bring back all columns from all involved tables, and that's going to add up fast. If the index isn't covered, each row from each table is necessarily going to be at least one physical seek and probably more than one.

The performance difference will also depend on hardware. Extra seeks won't matter as much for solid state devices as they would for mechanical storage. But by touching data you don't need, you're also polluting the cache in the whole stack -- on the drives, on the controllers, the processor, the RDBMS memory cache, and the PHP layer itself needs to build and store the associative array for a bunch of data you know you're not using.

The performance difference is always non-zero, and its exact effect isn't always easy to measure. If you've got headroom to burn, that's great. But you've probably wasted some money, in that case. And you're burdening someone else who will need to come along and clean up your mess eventually. They'll have a heavy burden, since your sloppy technique left a subtle trap. (For example, since the performance difference is plan dependent, you might be just fine now but blown completely out of the water when the query changes, the tables change, the indexes on those tables change, or someone upgrades the RDBMS. Even subtler actions might trigger trouble.)

I don't think there can be much debate about the benefits of the coding style. "*" ends up causing code to be brittle, and it's just planting a land mine for someone else to trip.

... Mike


On Mon, Feb 18, 2013 at 3:28 PM, Mark Steudel <[address removed]> wrote:
What are people's thoughts on "SELECT *" these days. With today's processing, disk speeds, memory, etc. does it really make a performance difference? If you look at most ORMs these days when you do something like:

$user = User::find( $user_id );

It's doing:

SELECT * FROM users WHERE user_id = ?

And that doesn't include any relationships ....

Thoughts?

MS


On Mon, Feb 18, 2013 at 2:56 PM, Mike Blaszczak <[address removed]> wrote:
It's not the cause of your problem, but it is bad form to use "SELECT *". You're probably getting more columns back than you're using, which is wasteful for I/O on disk and on the network. You're also referencing columns by name alter on, and your SQL statement will work even if those column names change, but your PHP will fail if they change.

... Mike


On Mon, Feb 18, 2013 at 1:43 PM, max steinmetz <[address removed]> wrote:
Hello, newb here with a question.

I'm attempting to build a simple shopping cart, this is my first time doing so and I am getting an error message which reads as follows:


Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in


Any help would be greatly appreciated as I'm google this error messag a bit and seen so many possible options that my mind turned to goop.

Again thank you for any help/direction possible.



This is the code starting with line #42

<div class="container">
<span class="top-label">
<span class="label-txt">PRODUCTS (TAKE Displayed things from here)</span>
</span>
<div class="content-area">
<div class="content drag-desired">
<?php
$result = mysql_query("SELECT * FROM internet_shop");
while($row=mysql_fetch_assoc($result))
{
echo '<div class="product"><img src="_img/products/'.$row['img'].'" alt="'.htmlspecialchars($row['name']).'" width="128" height="128" class="pngfix" /></div>';
}
?>
<div class="clear"></div>
</div>
</div>
<div class="bottom-container-border">
</div>
</div>





--
Please Note: If you hit "REPLY", your message will be sent to everyone on this mailing list ([address removed])
This message was sent by max steinmetz ([address removed]) from The Seattle PHP Meetup Group.
To learn more about max steinmetz, visit his/her member profile
Set my mailing list to email me As they are sent | In one daily email | Don't send me mailing list messages

Meetup, POB 4668 #37895 NY NY USA 10163 | [address removed]





--
Please Note: If you hit "REPLY", your message will be sent to everyone on this mailing list ([address removed])
This message was sent by Mike Blaszczak ([address removed]) from The Seattle PHP Meetup Group.
To learn more about Mike Blaszczak, visit his/her member profile



--
-----------------------------------------
Mark Steudel
P: [masked]
F: [masked]
[address removed]

. : Adoption Updates : .
http://www.steudel.org/blog

. : Work : .
http://www.mindfulinteractive.com

. : LinkedIn : .
http://www.linkedin.com/in/steudel




--
Please Note: If you hit "REPLY", your message will be sent to everyone on this mailing list ([address removed])
This message was sent by Mark Steudel ([address removed]) from The Seattle PHP Meetup Group.
To learn more about Mark Steudel, visit his/her member profile
Set my mailing list to email me As they are sent | In one daily email | Don't send me mailing list messages

Meetup, POB 4668 #37895 NY NY USA 10163 | [address removed]

Our Sponsors

  • PluralSight

    PluralSight subscriptions for developer training

  • O'Reilly

    Disc Code: PCBW is good for 40% off print and 50% off ebooks and videos

  • JetBrains PhpStorm

    Occasional free licenses to raffle off at meetups

  • DynaTrace

    Find yourself, promote yourself, stay true to yourself.

People in this
Meetup are also in:

Sign up

Meetup members, Log in

By clicking "Sign up" or "Sign up using Facebook", you confirm that you accept our Terms of Service & Privacy Policy