Forum Stats

  • 3,826,768 Users
  • 2,260,705 Discussions
  • 7,897,072 Comments

Discussions

Fetch one column from one row by id

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

Should a Procedure be made for a simple query??

query:

select name from posts where id = $id; ?

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

Any performance considerations?

Thanks Max

Answers

  • Christopher Jones-Oracle
    Christopher Jones-Oracle Member Posts: 1,648 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.