As one of the core technologies of the Semantic Web, the RDF data model enables us to represent machine-readable metadata about Web resources. SPARQL is the standard query language for answering queries from RDF data. In order to support SPARQL in practice, it is important to access such metadata quickly from large scale RDF data stores, such as Gene Ontology and DBpedia. In this paper, we present an algorithm that decides the solve order of an inputed query. We formalize the search space reduction of the connected variables occurring in a query and establish the costs of different query patterns. In particular, we consider selecting one of the various orders of elements in each query that results in less computation for searching and reasoning steps, i.e., matching a subgraph of a complex RDF graph. Using the algorithm, we implement an efficient query system with a RDF store (called NodeStore) for large-scale RDF data. In the RDF store, an indexed data structure of RDF graphs is well constructed for optimizing RDF data processing, e.g., finding a set of RDF triples including a common resource. For the evaluation of deciding the solve order of a query, we show some experimental results for our query system NodeStore and the Jena framework using a LUBM dataset (a benchmarking framework for semantic repositories).