首页 \ 问答 \ LLVM中的可变参数(Varargs in LLVM)

LLVM中的可变参数(Varargs in LLVM)

我可以在LLVM中定义可变参数函数,如果是的话我怎样才能访问它的参数?


Can I define a vararg function in LLVM, if yes how can I access its arguments?


原文:https://stackoverflow.com/questions/5508331
更新时间:2023-10-08 09:10

最满意答案

如果没有正在运行的测试系统,找到适合您问题的解决方案并不容易。

我发现可疑的是,第一个查询的每个结果行都会调用第二个方法,而且似乎每次打开和关闭数据库连接。 (你的ConnectionHandler可能会实现正确的连接池,但我无法在不知道代码的情况下判断它。如果每次都真正打开和关闭连接,这是你代码中最昂贵的事情)。

但即使使用正确的连接池,第二种方法也会为每次调用创建并执行新的SQL语句。 这称为N + 1选择查询问题

所以我建议进行以下改进:

  1. 尝试将两个SQL语句合并为一个(可能使用嵌套的SELECT等)。 那么你不能执行1 + N个查询,这将大大减少执行时间。

  2. 如果这不可能,请至少使用PreparedStatement作为第二种方法。 确保在进入循环之前创建一次预准备语句。 所以你必须在第一种方法中创建和准备它。 因此,您需要第二个数据库连接。 循环之后也分别打开和关闭它。

  3. 另一种策略:运行第一个查询,迭代结果集并将所有regCodes放入列表中。 关闭查询后, 通过PreparedStatement使用批处理来处理所有regCodes 。 另一个优点:因此只需要一个数据库连接。

顺便说一下:像Hibernate这样的成熟对象关系映射框架已经提供了开箱即用的策略,以避免或至少减轻1 + N选择问题。


It is not easy to find a proper solution to your problem without having a running test system to play around.

What I find suspicious is the fact that your 2nd method is called for every single result row of your first query, and it seems to open and close database connections every single time. (Your ConnectionHandler might implement proper connection pooling, but I cannot judge this without knowing the code. If the connection is really opened and closed every time, this is by far the most expensive thing in your code).

But even with proper connection pooling, your 2nd method creates and executes a new SQL statement for every call. This is called the N+1 Select Query Issue.

So I suggest the following improvements:

  1. Try to merge both SQL statements into a single one (maybe using nested SELECTs, etc.). Then you must not execute 1+N queries, which will greatly reduce execution time.

  2. If that's not possible, use at least a PreparedStatement for the 2nd method. Make sure to create the prepared statement just once before entering the loop. So you'll have to create and prepare it in the first method. Therefore, you need a second database connection. Open and close it before respectively after the loop too.

  3. Another strategy: Run the first query, iterate the result set and put all regCodes in a list. After closing the query, use batch-processing via PreparedStatement to work off all the regCodes. Another advantage: Therefore only one database connection is required.

Btw.: Mature object-relational mapping frameworks like Hibernate already provide these strategies out of the box to avoid or at least extenuate the 1+N select problem.

相关问答

更多
  • 如果没有正在运行的测试系统,找到适合您问题的解决方案并不容易。 我发现可疑的是,第一个查询的每个结果行都会调用第二个方法,而且似乎每次打开和关闭数据库连接。 (你的ConnectionHandler可能会实现正确的连接池,但我无法在不知道代码的情况下判断它。如果每次都真正打开和关闭连接,这是你代码中最昂贵的事情)。 但即使使用正确的连接池,第二种方法也会为每次调用创建并执行新的SQL语句。 这称为N + 1选择查询问题 。 所以我建议进行以下改进: 尝试将两个SQL语句合并为一个(可能使用嵌套的SELECT ...
  • 您可能想尝试复合索引 (bound_time, user_id, direction) 包含您需要的所有字段,可以非常有效地缩小日期范围。 You may want to try a compound index on (bound_time, user_id, direction) Contains all the fields you need and can be narrowed by the date range very efficiently.
  • 在第一个查询中,只需要10秒的睡眠时间,而在第二个查询中,如果它是123或者没有,则每个ID都被检查,如果没有,则睡眠10秒。 在where子句中使用sleep就像检查数据库中的每一行,除了它与您的案例中的值123相匹配的那一行。 In the first query it takes just 10 second sleep time while in the second one every id is being checked if it is 123 or not and if not it sl ...
  • 一些建议: GROUP BY子句中的列是否已编入索引? 如果没有,那么这将减慢查询速度。 “ID”列是否标记为主键? 如果不是那么他们应该。 在许多现代RDBMS中,标记为主键的列是自动索引的 你在外键上指定了索引吗? 那是a.DistID,d.rankID等。如果没有,那么索引你的FK列将加速查询 使用返回表的函数可能不是一个好主意。 如果在SQL Server中执行此操作,则查询优化器无法优化查询的该部分。 希望这可以帮助。 Some suggestions: Are the columns in th ...
  • 要匹配的字符串开头的%使得它无法使用索引。 开头的通配符使索引无效,MySQL必须在每一行的该列中进行搜索。 它不能跳过。 如果您知道要搜索的项目位于字段开头的开头,则可以删除开头'%'。 但是,如果你正在寻找'史蒂夫',我的回答将会回归'史蒂夫','史蒂文','史蒂夫老板',而不是'boss-steve'或'realsteve'。 I removed this query so it wont show the total result count when a search is done. Seems ...
  • 我所做的只是请求所有文件,并在前端找出来。 它减少了ajax调用的时间,我只是在我的前端过滤掉了,它执行速度快,不会保持服务器。 All I did, was request all the documents, and figure it out in the front-end. It reduced the time of the ajax call and I just filtered it out in my front-end which performs quick and doesn't ...
  • executeQuery应该用于期望返回结果的查询。 尝试使用executeUpdate ,看看是否有帮助。 可能是您的应用正在等待接收永不返回的结果。 由汤姆H 谢谢汤姆。 executeQuery should be used for queries that are expected to return results. Try executeUpdate instead and see if that helps. It could be that your app is waiting to re ...
  • 试试这个(没有GROUP BY ): SELECT upd.*, usr.username AS `username`, usr.profile_picture AS `profile_picture` FROM updates AS upd LEFT JOIN users AS usr ON upd.uid = usr.uid WHERE upd.deleted='0' AND ( ...
  • 在所有用于分组的字段上,您需要索引WHERE子句中使用的所有字段,在表所连接的所有字段上(您需要立即明确说明您的连接条件,您将获得笛卡尔连接)以及用于排序的所有字段。 最后一个问题是那里的HAVING子句。 你根本无法使用索引,因为它是一个计算值。 如果这是您经常在系统中使用的查询(即不仅仅用于报告),您可以考虑添加一个字段,您可以将其用作此过滤目的的标志。 每当您在任何查询中设置c_done_meetings.MEDONE_ATTEND = 'u'时,您也可以为成员或用户或与之关联的任何内容设置此标志,以 ...
  • 当你真的没有理解问题的核心时,我不确定你为什么接受了答案。 我还想澄清这是一个mysql问题,而且你在使用PDO或PHP的事实并不重要。 人们建议你使用EXPLAIN。 我会更进一步告诉你,你需要使用EXPLAIN EXTENDED格式= json选项来全面了解正在发生的事情。 看看你的解释屏幕截图,你应该跳出来的是查询超过1米的行来获得答案。 这就是为什么你的查询花了这么长时间! 在一天结束时,如果您已正确索引表,那么您的目标应该在这样的大表中,以使检查的行数与最终结果集非常接近。 那么让我们看看第二个查 ...

相关文章

更多

最新问答

更多
  • 获取MVC 4使用的DisplayMode后缀(Get the DisplayMode Suffix being used by MVC 4)
  • 如何通过引用返回对象?(How is returning an object by reference possible?)
  • 矩阵如何存储在内存中?(How are matrices stored in memory?)
  • 每个请求的Java新会话?(Java New Session For Each Request?)
  • css:浮动div中重叠的标题h1(css: overlapping headlines h1 in floated divs)
  • 无论图像如何,Caffe预测同一类(Caffe predicts same class regardless of image)
  • xcode语法颜色编码解释?(xcode syntax color coding explained?)
  • 在Access 2010 Runtime中使用Office 2000校对工具(Use Office 2000 proofing tools in Access 2010 Runtime)
  • 从单独的Web主机将图像传输到服务器上(Getting images onto server from separate web host)
  • 从旧版本复制文件并保留它们(旧/新版本)(Copy a file from old revision and keep both of them (old / new revision))
  • 西安哪有PLC可控制编程的培训
  • 在Entity Framework中选择基类(Select base class in Entity Framework)
  • 在Android中出现错误“数据集和渲染器应该不为null,并且应该具有相同数量的系列”(Error “Dataset and renderer should be not null and should have the same number of series” in Android)
  • 电脑二级VF有什么用
  • Datamapper Ruby如何添加Hook方法(Datamapper Ruby How to add Hook Method)
  • 金华英语角.
  • 手机软件如何制作
  • 用于Android webview中图像保存的上下文菜单(Context Menu for Image Saving in an Android webview)
  • 注意:未定义的偏移量:PHP(Notice: Undefined offset: PHP)
  • 如何读R中的大数据集[复制](How to read large dataset in R [duplicate])
  • Unity 5 Heighmap与地形宽度/地形长度的分辨率关系?(Unity 5 Heighmap Resolution relationship to terrain width / terrain length?)
  • 如何通知PipedOutputStream线程写入最后一个字节的PipedInputStream线程?(How to notify PipedInputStream thread that PipedOutputStream thread has written last byte?)
  • python的访问器方法有哪些
  • DeviceNetworkInformation:哪个是哪个?(DeviceNetworkInformation: Which is which?)
  • 在Ruby中对组合进行排序(Sorting a combination in Ruby)
  • 网站开发的流程?
  • 使用Zend Framework 2中的JOIN sql检索数据(Retrieve data using JOIN sql in Zend Framework 2)
  • 条带格式类型格式模式编号无法正常工作(Stripes format type format pattern number not working properly)
  • 透明度错误IE11(Transparency bug IE11)
  • linux的基本操作命令。。。