Long query in Amazon Redshift never return
I am facing a weird problem when running long queries in Amazon Redshift (>30min). Such queries do not provide feedback upon completion, even though they are completed when looking through the Redshift console or querying the stv tables.
You can try to add ?tcpKeepAlive=true at the end of the connection string. I find it helpful in some long running queries.
The same goes for other TCP keep alive settings for your operating system.
For example, for Mac:
sudo sysctl -w net.inet.tcp.always_keepalive=1
You would probably also want to optimize your queries not to take too long time. There are many options for that, depends on your actual queries. But a quick improvement you can get with the new SSD based nodes: http://aws.amazon.com/about-aws/whats-new/2014/01/23/amazon-redshift-ssd-node-type/
I suppose you have a problem with connection timing out.
If your query should return some rows (SELECT), maybe try to UNLOAD result into S3 bucket?
UNLOAD (' YOUR LONG RUNNING SELECT HERE ') TO 's3://some_bucket/some/path/to/files' WITH CREDENTIALS AS 'aws_access_credentials'
Keep in mind, that this will create multiple files (at least one per node) and you will have to merge them into one.