Skip to content

error: could not open relation with OID 16100645

0

I occasionally encounter an error while executing the query below. However, when I rerun the query after the error occurs, it runs successfully. What could be causing this error?

WITH trial_courses AS (
    SELECT _id, title
    FROM dbonline_v2_courses
    WHERE __hevo__marked_deleted = FALSE AND  is_trial = true
),
-- 항해 결제자
hh_paid AS (
    SELECT onlineuserid
    FROM dbhanghae_v2_applicants
    WHERE __hevo__marked_deleted = FALSE AND  funnelid = '61066b826c10bd0689a3148a'
),
-- 내배캠 강의
gov_camp_courses AS (
    SELECT _id
    FROM dbonline_v2_courses
    WHERE __hevo__marked_deleted = FALSE AND  is_gov_training = true
),
-- 내배캠 합류자
gov_camp_enroll AS (
    SELECT user_id
    FROM dbonline_v2_enrolleds
    WHERE __hevo__marked_deleted = FALSE AND  course_id IN (SELECT _id FROM gov_camp_courses) 
    AND is_registered = True
),


main AS (
SELECT 
    distinct(us._id) as user_id,
    us.phone,
    us.name,
    co.title,
    start_date,
    current_date,
    end_date,
    erd.updated_at,
    extract(year from sysdate) - birthyear as age
from dbonline_v2_enrolleds erd
left join dbonline_v2_courses co
on erd.course_id = co._id
left join dbonline_v2_users us
on erd.user_id = us._id
where nvl(us.name, '') != ''
and us.phone is not null
and us.name is not null
and erd.__hevo__marked_deleted = false
and us.is_test is not true
and us.marketing = 'true'
and co._id = '65b31ccd173c32f5c61bdf29'
)


SELECT *
FROM main as o
WHERE age between 20 and 35
-- 항해 결제자 제외
AND NOT EXISTS (
    SELECT 1
    FROM hh_paid hp
    WHERE hp.onlineuserid = o.user_id
)
-- 내배캠 합류자 제외
AND NOT EXISTS (
    SELECT 1
    FROM gov_camp_enroll gc
    WHERE gc.user_id = o.user_id
)

asked 2 years ago230 views

1 Answer
0

OID is the (Object Identifier) , it means that the problem should be in the used data that can be going missing ( if your using redshift spectrum for example to read externa schema or s3 files ) or corrupted data ..

you can run this quick check to help identify the problem more : SELECT * FROM pg_class WHERE oid = 16100645;

answered a year ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Relevant content