从Python执行Vertica查询时,执行时间超过了运行时上限

2024-05-20 00:01:12 发布

您现在位置:Python中文网/ 问答频道 /正文

我有一个在Vertica DB上运行的SQL查询,大约25分钟后完成(使用DataGrip)

但是,当使用vertica_Python包从Python执行查询时,由于运行时间上限,20分钟后将失败,并显示以下错误消息:

vertica_python.errors.QueryCanceled: Severity: ERROR, Message: Execution time exceeded run time cap of 00:20, Sqlstate: 57014

显然,只有当查询从Python运行时,才会启用运行时上限,因为当查询在超过20分钟后从DataGrip运行时,它会成功

下面是一个简单的代码示例:

import pandas as pd
from vertica_python import connect

query = "SELECT * FROM ..."
vertica_connection_info = {"host": hst, "port": prt, "user": usr, "password": pwd}
connection = connect(**vertica_connection_info)
cur = connection.cursor()
cur.execute(query)
result = cur.fetchall()
columns = [d.name for d in cur.description]
df = pd.DataFrame(result, columns=columns)

我想将RUNTIMECAP从20m更改为30m,但找不到它的配置位置


Tags: columnsimportinfodbsqltimeconnectresult
1条回答
网友
1楼 · 发布于 2024-05-20 00:01:12

我希望您能够使用Python客户端启动一个简单的原始命令:

在这里,我使用我的普通sql客户机:vsql。我询问Vertica我被分配到哪个资源池,然后我再次询问Vertica我被分配到的资源池的设置:

marco ~/1/Vertica/supp $ vsql
Welcome to vsql, the Vertica Analytic Database interactive terminal.

Type:  \h or \? for help with vsql commands
       \g or terminate with semicolon to execute query
       \q to quit

sbx=> show resource pool;
     name      | setting 
       -+    -
 resource_pool | general
sbx=> \pset null '(null)'
Null display is "(null)".
sbx=> select * from resource_pools where name='general';
-[ RECORD 1 ]      +         
pool_id                  | 45035996273704996
name                     | general
subcluster_oid           | 0
subcluster_name          | (null)
is_internal              | t
memorysize               | 
maxmemorysize            | Special: 95%
maxquerymemorysize       | 
executionparallelism     | AUTO
priority                 | 0
runtimepriority          | MEDIUM
runtimeprioritythreshold | 2
queuetimeout             | 00:05
plannedconcurrency       | AUTO
maxconcurrency           | (null)
runtimecap               | (null)
singleinitiator          | f
cpuaffinityset           | (null)
cpuaffinitymode          | ANY
cascadeto                | (null)
cascadetosubclusterpool  | (null)

sbx=> 

因此,我目前正在使用资源池general运行—其运行时上限设置为NULL—因此,永远不会

您将被分配到一个不同于general的资源池,并且您的SELECT * FROM resource_pools WHERE name='<<your resource pool_s name>>'将返回00:20for runtimecap。您必须要求您的数据库管理员(或有权更改资源池的其他人)更改该运行时上限值,或者为您创建一个不同的资源池,并在默认情况下将您分配给它

相关问题 更多 >