multi-query

Which one is faster single big query or few small queries?

六眼飞鱼酱① 提交于 2020-01-02 13:58:10
问题 So I want to grab data from database, which method is faster, create several queries or one multi-query ? 回答1: Each "round trip" to the database will have some overhead. So the fewer round-trips, the less overhead. Consider also that fewer requests means fewer packets from client to server. If the result of the consolidated query gives you just what you want, then single query is the way to go. If your single query is returning extra or redundant data (perhaps because of de-normalization)

Java - Mysql - Multiple query

二次信任 提交于 2019-12-25 12:25:47
问题 String qLink = ""; qLink = "INSERT INTO trackgps.queclinklogs(Supplier,NtwProtocol,IMEI,log,DBTIME)" + "VALUES" + "(" + "'" + supplier + "',"+ "'" + protocol + "',"+ "'" + failedQIMEI + "',"+ "'" + failedQLog + "',"+ "'" + currentQuecTimestamp + "'" + ")," + "(" + "'" + supplier + "'" + "," + "'" + protocol + "'" + "," + "'" + QuecLinkIMEI + "'" + "," + "'" + data2 + "'" + "," + "'" + currentQuecTimestamp + "'" + ")"; Statement stmtLink = connQ.createStatement(); stmtLink.execute(qLink);

How to execute 2 or more SQL queries in PHP without joining tables [duplicate]

流过昼夜 提交于 2019-12-23 06:08:22
问题 This question already has an answer here : mysqli_fetch_assoc() expects parameter / Call to a member function bind_param() errors. How to get the actual mysql error and fix it? (1 answer) Closed 3 years ago . To select data from 1 table I'm using following code: if(isset($UserID)) { $users = $con->prepare(" SELECT DISTINCT d.FirstName ,d.LastName ,d.Picture FROM Details d WHERE d.UserId = ? "); $users->bind_param('i', $GetUserId); $users->execute(); $users->bind_result( $FirstName, $LastName,

PHP MySQL Multi-statement works on my webpage but not on XAMPP

心不动则不痛 提交于 2019-12-13 04:03:50
问题 So I use this code to connect to MySQL and execute multiple statements: $connect=@mysql_connect($host,$user,$pass,false,65536) or die("Can't connect"); mysql_select_db($base,$connect); When connected I do: mysql_query("CREATE TABLE IF NOT EXISTS tablename ...;\nINSERT INTO tablename ...;"); I use this code to execute backup files containing the same code above (\n=new line). When I run this script on my webpage (hosted server) it works but on my local computer where I use XAMPP it shows an

NHibernate Multiquery for eager loading without joins

↘锁芯ラ 提交于 2019-12-09 07:53:55
问题 Is it possible to use a multiquery and have two hql queries returning two different sets of entities where one of the sets are used in the other and that the session "fixes" this via the first level cache? E.g. scenario (a dumb one and it could be solved with joins) public class Room { ... public virtual ISet<Bookings> Bookings {get;set;} public virtual bool IsAvailible {get;set;} ... } public class Booking { ... } After executing a multicriteria with two hql's: returning all rooms where

Executing multiple queries in codeigniter that cannot be executed one by one

左心房为你撑大大i 提交于 2019-12-08 15:00:19
问题 I have an "event" table. For simplicity, you can imagine that it should be like a hierarchical category . It uses the nested set model (Thanks to Mark Hillyer for his post at http://mikehillyer.com/articles/managing-hierarchical-data-in-mysql/) My code: $query = "LOCK TABLE event WRITE; SELECT @ParentRight := parent.rgt, @Level := parent.level FROM event AS parent WHERE parent.id = '{$data['parent_id']}'; UPDATE event SET rgt = rgt + 2 WHERE rgt > @ParentRight; UPDATE event SET lft = lft + 2

Which one is faster single big query or few small queries?

这一生的挚爱 提交于 2019-12-06 08:17:19
So I want to grab data from database, which method is faster, create several queries or one multi-query ? Each "round trip" to the database will have some overhead. So the fewer round-trips, the less overhead. Consider also that fewer requests means fewer packets from client to server. If the result of the consolidated query gives you just what you want, then single query is the way to go. If your single query is returning extra or redundant data (perhaps because of de-normalization) then the overhead savings of a single round trip may be lost in the extra data transferred. Another

PHP PDO Transactions?

你。 提交于 2019-12-04 07:40:18
问题 I have a signup page and basically I need data inserted into 4 tables. I'm new to PDO and am confused over something. Basically if any of the inserts fail I don't want anything added to the database, that seems simple enough. My confusion is, I need to first insert the users username, email, password etc in my users table so I can get (not sure how) using PDO the uid MySQL has given my user (auto incremented by mysql). I need the user uid MySQL gave my user for the other tables as the other

NHibernate Multiquery for eager loading without joins

纵饮孤独 提交于 2019-12-03 08:57:49
Is it possible to use a multiquery and have two hql queries returning two different sets of entities where one of the sets are used in the other and that the session "fixes" this via the first level cache? E.g. scenario (a dumb one and it could be solved with joins) public class Room { ... public virtual ISet<Bookings> Bookings {get;set;} public virtual bool IsAvailible {get;set;} ... } public class Booking { ... } After executing a multicriteria with two hql's: returning all rooms where IsAvailible = true returning all bookings having a room that has a room that IsAvailible when accessing a

Is there an equivalent for MySQL's “multi_query()” in PDO?

北慕城南 提交于 2019-12-02 18:49:47
问题 I like assembling multiple SQL queries into one string and executing them simultaneously to ensure that they are executed atomically. I can't seem to do this with PDO like I could with the MySQL functions though. Any thoughts? 回答1: Sending at once multiple queries to the MySQL server - won't make them atomic. For atomicity, use transactions. Read: ACID @ wikipedia 来源: https://stackoverflow.com/questions/6832501/is-there-an-equivalent-for-mysqls-multi-query-in-pdo