I am not able to view my query result when I do query on hive shell(even its executing successfully).
when I do "show tables;" its displaying list of tables as below
hive> show tables;
OK
bucketed_users
logs
managed_table
records
student
students
tweets
user
but when I do any query its executing but its not displaying output
EG:
hive> select * from students;
OK
Time taken: 0.164 seconds
Is there any settings required to print output on my console or is there any issues with my hive shell. please help on this....
I created the table one day before I ran the select query. I discovered that there is no data in the students table. I don't know how the data got lost.
When I dropped and recreated the "Students" table, I was able to run all queries on it fine.
Related
I have a append only table with more than ~80M records attached to timescaledb, the frequency of insertion of records to table is one minute. Also, there is an index created on non unique column and start time (ds_id, start_time).
When I try to run the simple
select * from observation where ds_id in (27525, 27567, 28787,27099)
The query itself is taking longer than 1 minute to give the output.
I, also tried to analyze the table, as it is append only there is no scope of vacuum on this table.
So, I am in confusion why the simple select query is taking much time. I am thinking due to huge number of records it is taking time to query the results.
Please help me in understanding the issue and help me with fixing
query plan: https://explain.depesz.com/s/M8H7
Thanks in advance.
Note: ds_id (fk) and start_time(insertion time) are the one used for getting results. Also, I am sorry for not providing the table structure and details as it is confidential. :(
I'd like to query postgresql view via presto. I've found some old links/notes that it should be possible. Unfortunately I don't have any views listed in SHOW TABLES command and when I tried to query data select cnt from umcount I got Table 'public.umcount' not found. How to query views then?
I'm using Presto 0.205
You can try out these queries first:
show schemas from <connector_name>
show tables from <connector_name>.<schema_name>
If everything works fine then use these prefixes in your select queries.
For example:
select * from <connector_name>.<schema_name>.<table_name> limit 10
I have a table of users in S3 that I'm running some queries against. In particular, I'm trying to get a count of records for a particular user ID. I start by querying the entire table as:
Select *
From table
Limit 100
That works just fine and returns results. I then copy one of the user ID's that I get from that result and run this query:
Select count(id)
From table
Where id = 'abc123'
Since I copied the user ID directly from the table I should get a count of at least 1 - as I know there is at least one record for that ID. However, Hive returns a result of 0.
I have tried analyze table to compute statistics and then re-ran my query and still got a count of 0.
So I then tried the following code but this timed out on me and wouldn't show any results. It took the query 0.001 seconds to run but then it just sat there "loading..." the table and then I eventually get a message saying "Operation timed out."
Select *
From table
Where id = 'abc123'
Limit 100
Any thoughts on why this may be happening or how to fix it?
Thanks!
I have 3 rather simple tables in Postgres that record which IDs were valid for each business date going back several years. The three tables represent 3 sources that record activity from these IDs. I can't give you the entire table, but imagine:
Date ID
2000-01-02 1
2000-01-02 2
2000-01-02 3
2000-01-02 4
. . .
2018-01-02 49997
2018-01-02 49998
2018-01-02 49999
2018-01-02 50000
So each table has daily data with potentially tens of thousands of IDs. Not all IDs show up on all days in all tables, so all I want is a view that gives me the master list of any ID that shows up on any of the tables on any of the days. Simple:
create view all_ids as
select distinct * from table1 union
select distinct * from table2 union
select distinct * from table3;
The view is created without any problem but it proves impossible to query. If I want to see what days a single id shows up on, I would write:
select * from all_ids where id=37;
The problem is that when Postgres runs this query, it first attempts to create a huge temporary table that is the union of the 3 tables. This, unfortunately, exceeds the temp_file_limit (5767168kB), and as I am not an admin, I cannot change the temp_file_limit. Regardless, this seems to contradict my understanding of how views even work. Please note: I can query an id or list of ids from any of the individual tables just fine.
I can write this as a function that I can pass specific IDs, but again, I believe that the view itself is supposed to handle this by returning just what I am asking for rather than creating the universe of data in memory first and then selecting from it.
Other relevant information is that we're using an old version of Postgres, 9.2.23. I am thinking there is something wrong about how it is handling views. The answer may be to bug out admin to upgrade this.
Any ideas?
What you are looking for is materialized views. I will just quote from the docs::
CREATE VIEW defines a view of a query. The view is not physically materialized. Instead, the query is run every time the view is referenced in a query.
The view that you have created all_ids, like you said, gets re-created every time this view is referenced.
Edit applies to Postgres 9.3+
At my work, I needed to build a new join table in a postgresql database that involved doing a lot of computations on two existing tables. The process was supposed to take a long time so I set it up to run over the weekend before I left on Friday. Now, I want to check to see if the query finished or not.
How can I check if an INSERT command has finished yet while not being at the computer I ran it on? (No, I don't know how many rows it was suppose to add.)
Select * from pg_stat_activity where state not ilike 'idle%' and query ilike 'insert%'
This will return all non-idle sessions where the query begins with insert, if your query does not show in this list then it is no longer running.
pg_stat_activity doc
You can have a look at the table pg_stat_activity which contains all database connections including active query, owner etc.
At https://gist.github.com/rgreenjr/3637525 there is a copy-able example how such a query could look like.