0
私は、テキスト[]を検索し、それをテキスト[]と交差させて、私が動的に計算するselect文の交差をしようとしています。ポストグルのタイプの不一致INTERSECT
私はこのスクリプトを実行すると、私はこのエラーをどのように修正すればよい
ERROR: INTERSECT types text[] and text cannot be matched
エラーが出ますか?私のテーブルの
do $$
declare
p json;
total_time float;
t float;
arr text[];
query1 text;
arr := '{}';
for j in 80..120 loop
arr := array_append(arr, j::text);
query1 := 'select sub_id from table where main_id=1 INTERSECT select unnest($1)';
execute 'explain (analyse, format json) ' || query1 using arr into p;
t := (p->0->>'Planning Time')::float + (p->0->>'Execution Time')::float;
total_time := total_time + t;
end loop;
スキーマ:
db=# \d+ table
Table "table"
Column | Type | Modifiers | Storage | Stats target | Description
---------------+---------+-----------+----------+--------------+-------------
main_id | integer | | plain | |
sub_id | text[] | | extended | |