% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/verb-compute.R
\name{compute.tbl_sql}
\alias{compute.tbl_sql}
\title{Save results into a new remote table}
\usage{
\method{compute}{tbl_sql}(
  x,
  name = NULL,
  temporary = TRUE,
  overwrite = FALSE,
  unique_indexes = list(),
  indexes = list(),
  analyze = TRUE,
  ...,
  sql_options = NULL,
  cte = deprecated()
)
}
\arguments{
\item{x}{A lazy data frame backed by a database query.}

\item{name}{Name of new remote table. Use a string to create the table
in the current catalog/schema. Use \code{I()} to create the table in a specific
catalog/schema, e.g. \code{I("schema.table")}.}

\item{temporary}{if \code{TRUE}, will create a temporary table that is
local to this connection and will be automatically deleted when the
connection expires}

\item{overwrite}{If \code{TRUE}, will overwrite an existing table with
name \code{name}. If \code{FALSE}, will throw an error if \code{name} already
exists.}

\item{unique_indexes}{a list of character vectors. Each element of the list
will create a new unique index over the specified column(s). Duplicate rows
will result in failure.}

\item{indexes}{a list of character vectors. Each element of the list
will create a new index.}

\item{analyze}{if \code{TRUE} (the default), will automatically ANALYZE the
new table so that the query optimiser has useful information.}

\item{...}{Ignored.}

\item{sql_options}{SQL rendering options generated by \code{\link[=sql_options]{sql_options()}}.}

\item{cte}{\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#deprecated}{\figure{lifecycle-deprecated.svg}{options: alt='[Deprecated]'}}}{\strong{[Deprecated]}}
Use the \code{sql_options} argument instead.}
}
\description{
\code{compute()} executes the query and stores the results in a new remote table.
This is useful when you want to cache intermediate results for reuse or to
improve performance by avoiding repeated computation of complex queries.
}
\examples{
library(dplyr, warn.conflicts = FALSE)

db <- memdb_frame(a = c(3, 4, 1, 2), b = c(5, 1, 2, NA))
db |> filter(a <= 2) |> show_query()
db |> filter(a <= 2) |> compute() |> show_query()
}
