Forum Stats

  • 3,876,189 Users
  • 2,267,078 Discussions


Fetch one column from one row by id

user4472042 Member Posts: 1
edited Feb 8, 2016 11:18PM in PHP

Should a Procedure be made for a simple query??


select name from posts where id = $id; ?

Whats faster in this small query. plain sql or procedure?

Any performance considerations?

Thanks Max


  • Christopher Jones-Oracle
    Christopher Jones-Oracle Member Posts: 1,656 Employee
    edited Feb 8, 2016 11:18PM

    What DOES matter is that you must use bind variables and never use string concatenation like 'select name from posts where id = $id;'

    You will destroy scalability.

    Regarding procedures, you really need to benchmark it yourself.  Your client machine, network and DB can all influence the absolute time for this.

    Performance isn't the only consideration: what is easier for you to maintain or secure?

    There will be an overhead going from the PL/SQL layer to the SQL layer.  Does it matter?  Maybe or maybe not.

This discussion has been closed.