首页 \ 问答 \ plsql怎么连接本地安装的oracle

plsql怎么连接本地安装的oracle

更新时间:2022-05-31 14:05

最满意答案

服务器端预处理语句使用服务器端资源来存储语句的执行计划。 阈值提供了一种启发式方法,可以“准备”实际使用的语句。 “经常”的定义默认为5。

请注意,服务器端预处理语句可能导致执行计划不佳,因为它们不基于准备期间传递的参数。 如果传递给预准备语句的参数对特定索引具有不同的选择性(例如),则预准备语句的常规查询计划可能不是最理想的。 作为另一个示例,如果您遇到查询执行远远大于创建解释计划的成本的情况,并且由于缺少绑定参数而未正确设置解释计划,则最好不要使用服务器端预备语句。

当驱动程序达到阈值时,它将按如下方式准备语句:

    if (!oneShot)
    {
        // Generate a statement name to use.
        statementName = "S_" + (nextUniqueID++);

        // And prepare the new statement.
        // NB: Must clone the OID array, as it's a direct reference to
        // the SimpleParameterList's internal array that might be modified
        // under us.
        query.setStatementName(statementName);
        query.setStatementTypes((int[])typeOIDs.clone());
    }

语句名称作为有线协议的一部分发送,它告诉Postgres准备服务器端。


Server side prepared statements consume server side resources to store the execution plan for the statement. The threshold provides a heuristic that causes statements that are actually used "often" to be prepared. The definition of "often" defaults to 5.

Note that server side prepared statements can cause poor execution plans because they are not based on the parameters passed during the prepare. If the parameters passed to a prepared statement have a different selectivity on a particular index (for example), then the general query plan of the prepared statement may be suboptimal. As another example, if you have a situation where the execution of the query is much greater than the cost to create an explain plan, and the explain plan isn't properly set due to lack of bind parameters, you may be better off not using server side prepared statements.

When the driver reaches the threshold, it will prepare the statement as follows:

    if (!oneShot)
    {
        // Generate a statement name to use.
        statementName = "S_" + (nextUniqueID++);

        // And prepare the new statement.
        // NB: Must clone the OID array, as it's a direct reference to
        // the SimpleParameterList's internal array that might be modified
        // under us.
        query.setStatementName(statementName);
        query.setStatementTypes((int[])typeOIDs.clone());
    }

The statement name is sent as part of the wire protocol, which tells Postgres to prepare it server side.

相关问答

更多
  • 服务器端预处理语句使用服务器端资源来存储语句的执行计划。 阈值提供了一种启发式方法,可以“准备”实际使用的语句。 “经常”的定义默认为5。 请注意,服务器端预处理语句可能导致执行计划不佳,因为它们不基于准备期间传递的参数。 如果传递给预准备语句的参数对特定索引具有不同的选择性(例如),则预准备语句的常规查询计划可能不是最理想的。 作为另一个示例,如果您遇到查询执行远远大于创建解释计划的成本的情况,并且由于缺少绑定参数而未正确设置解释计划,则最好不要使用服务器端预备语句。 当驱动程序达到阈值时,它将按如下方式 ...
  • 实际上,它看起来像java SQL解析器不符合hstore。 但是由于语法c ? 'foo' c ? 'foo'相当于exist(c, 'foo') ,您可以轻松解决此问题。 看看下面的页面,看看hstore的详细操作符是什么。 Postgres hstore文档 Effectively, it looks like the java SQL parser is not hstore compliant. But since the syntax c ? 'foo' is equivalent to exi ...
  • 实际上,我在Github与JDBC开发人员进行了接触,经过一些讨论后,似乎目前最好的解决方案是准备好以下声明: String query = "SELECT id, data FROM table_name WHERE data->'objects' @> ?::jsonb"; 并将整个搜索条件作为字符串化的JSON对象传递给参数: PreparedStatement st = connection.prepareStatement(query); st.setString(1, "[\"id\":" + ...
  • 感谢Craig Ringer向我指出了真正的问题,我重写了我的河流,用“\ u0027”替换postgresql json查询中的简单引号,现在它工作得很好 Thanks to Craig Ringer who pointed me to the real problem, I rewrited my river, replacing the simple quotes in the postgresql json query with "\u0027", and now it works just fin ...
  • 这是查询中的查询。 所以它需要在引号内引用。 为此,内部报价应加倍 : String sql = "select query_to_xml('select col1,col2,col3 FROM table where col4 = '||?||' and col5 = '||?||' and col6 = '''||?||'''', true,true,'');"; SQL文本' and col6 = '''将在服务器端解释为and col6 = ' , ''''将被解释为' ,因此你将在每一侧都有一个 ...
  • PostgreSQL JDBC驱动程序中存在一个问题。 从最新的PostgreSQL JDBC驱动程序源代码构建驱动程序返回了存储过程的正确元数据。 Driver: PostgreSQL 9.4 JDBC4.1 (build 1200) Parameter Name: itemid Paramter Type: 1 Data Type: 4 Parameter Name: id Paramter Type: 5 Data Type: 4 Parameter Name: name Paramter Type: ...
  • 根据文档 , DEALLOCATE是删除准备好的语句的唯一方法,强调补充说: 准备用于PQexecPrepared的语句也可以通过执行SQL PREPARE语句来创建。 另外,尽管没有用于删除准备好的语句的libpq函数 ,但可以将SQL DEALLOCATE语句用于此目的。 据推测,他们并没有费心为此公开C函数,因为这将如此简单: char query[NAMEDATALEN+12]; snprintf(query, sizeof(query), "DEALLOCATE %s", stmtName ...
  • 在PostgreSQL中,每个对象(无论是表,索引还是函数)都属于模式 。 正如您在评论中所说,您安装了扩展程序: SET SCHEMA 'dev'; CREATE EXTENSION pg_trgm; 我假设这些函数可以在dev shema中访问。 如果是这种情况,您应该能够以这种方式在JDBC中使用它们: SELECT id, name, dev.similarity(name, 'a') as similarity FROM dev.customer WHERE name % 'a' OR ...
  • prepareStatement的第二个参数应该是Statement.RETURN_GENERATED_KEYS或Statement.NO_GENERATED_KEYS之一。 我猜你想用 PreparedStatement prepareStatement(String sql, int resultSetType, int resultSetConcurrency) ...
  • JDBC驱动程序文档包含有关何时以及如何使用服务器端预处理语句的详细信息 。 无论如何,您显示的日志输出并不表示存在问题,因为任何查询都将被解析,绑定和执行。 JDBC驱动程序只选择执行这些步骤作为单独的协议步骤,而不是像Python驱动程序那样执行一步。 (我想你可能会争论网络开销。)大多数人关心准备语句的问题是参数在计划之后被替换,但这不是这里发生的事情,因为准备好的语句是在计划之后计划的。绑定步骤(与命名的预准备语句不同,它是在解析步骤之后计划的)。 您可以在协议文档中阅读这些详细信 ...

相关文章

更多

最新问答

更多
  • 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
  • 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
  • OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
  • 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
  • codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
  • 在计算机拍照在哪里进入
  • 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
  • No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
  • 单页应用程序:页面重新加载(Single Page Application: page reload)
  • 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
  • System.StackOverflow错误(System.StackOverflow error)
  • KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
  • 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
  • android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
  • TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
  • 企业安全培训的各项内容
  • 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
  • C#类名中允许哪些字符?(What characters are allowed in C# class name?)
  • NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
  • 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
  • 将多个行和可变行移动到列(moving multiple and variable rows to columns)
  • 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
  • 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
  • Angular $资源不会改变方法(Angular $resource doesn't change method)
  • 在Angular 5中不是一个函数(is not a function in Angular 5)
  • 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
  • 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
  • 常见的python rpc和cli接口(Common python rpc and cli interface)
  • Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
  • 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)